![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| convert Julian date to calender date | srikanthus2002 | Shell Programming and Scripting | 6 | 05-08-2007 06:27 AM |
| Find julian date for given corresponding date | srikanthus2002 | Shell Programming and Scripting | 2 | 10-10-2006 09:33 PM |
| Julian Dates and the Cal command | shan2on | Shell Programming and Scripting | 0 | 06-26-2006 05:32 PM |
| Calendar date to Julian and Back | BCarlson | Shell Programming and Scripting | 4 | 05-14-2005 05:18 PM |
| Converting YYYYMMDD to Julian | dfran1972 | Shell Programming and Scripting | 5 | 04-28-2005 10:34 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Julian Date
I have a shell script which gets passed a parameter which is a combination of Year and Julian Date <YYYYj>. So April 11th, julian date is 101. So if I wanted April 11th for 2003 I would get the following value 2003101. How would I convert that in unix to be 20030411? I am using the korn shell.
|
|
|||||
|
What you're doing is more of a day-of-year thing rather than a Julian number thing. But a Julian number calculator can handle this stuff easily.
Get the Julian number for the day before Jan 1 of the year in question: datecalc -j 2002 12 31 52639 Now calculate the JD of the date you want: 52740=52639+101 Lastly, convert that to a date: datecalc -j 52740 2003 4 11 Of course, you will want to read the output of the last command into some variables, not just display them. With ksh, this is really just a one-liner: Code:
Y=2003 DOY=101 datecalc -j $(($(datecalc -j $((Y-1)) 12 31) + DOY)) | read year month day I see oombera beat me to the punch here 8) Oh well, now you have two options.. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|