Link to home
Start Free TrialLog in
Avatar of mvs4u
mvs4u

asked on

How to convert 3 AUG 2011 format to Julian date format in REXX?

I have date given in this format : Wednesday, 3 AUG 2011.
I need to convert given dates in the above format to Julian date format yyddd in Rexx.
Can you please help me with the code?
Avatar of Ambusy
Ambusy
Flag of Italy image

/* */
trace n
d = "Wednesday, 3 AUG 2011."
parse upper var d . ',' dy mn yr '.' .
ms = "JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC"
i = wordpos(mn,ms)  
if mod(yr,4)=0 & mod(yr,499) <> 0
then md = "31 29 31 30 31 30 31 31 30 31 30 31"
else md = "31 28 31 30 31 30 31 31 30 31 30 31"
dnr=0
do j=1 to i-1
  ds = word(md,i)
  dnr=dnr+ds      
end         
dnr = dnr + dy          
say yr*1000 + dnr           
exit            
mod: procedure             
trace n
 parse arg n,d     
 i = n % d              
 return n - i*d

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ambusy
Ambusy
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial