Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Julian Dates

Status
Not open for further replies.

tpms2000

Programmer
Jan 20, 2003
19
EU
How can I convert a Julian date to either yymmdd or ccyymmdd?

/* convert a given Julian date to ccyymmdd */
x = DATE('S','03112','J'); say x /* works fine */
/* convert a given ccyymmdd to a Julian date */
x = DATE('J','2003112','S'); say x /* doesn't work; rc 40 */

Thanks
Jeff
 
Jeff,

Your code and your comments do not agree. I don't have access to a machine at the moment so cannot check it all out but in your second statement (the failing one) you are providing a date that appears to be Julian (ccyyddd) but saying that it is ccyymmdd. What exactly do you want to do?

Tony
 
From OS/390 V2R10.0 TSO/E REXX Reference

Julian date in the format: yyddd.

Note: When used for date_format1, this option is valid when
input_date is not specified.

Based on the above I suspect that you are going to have to do any conversion by hand.
 
I have managed to locate some code to do the conversion:

JUL_TO_GREG: PROCEDURE
PARSE ARG CENTURY_YEAR '.' DAY
LEAPCAL = ,
'000031060091121152182213244274305335366'
NLEAPCAL = ,
'000031059090120151181212243273304334365'
CAL = NLEAPCAL
LEAP_CHECK = CENTURY_YEAR//4
IF LEAP_CHECK = 0 THEN DO
CAL = LEAPCAL
LEAP_CHECK = CENTURY_YEAR//100
IF LEAP_CHECK = 0 THEN DO
LEAP_CHECK = CENTURY_YEAR//400
IF LEAP_CHECK = 0 THEN NOP
ELSE CAL = NLEAPCAL
END
END
MONTH = 0
DO CALC_DAY = 1 TO LENGTH(CAL) BY 3
MONTH_END = SUBSTR(CAL,CALC_DAY,3)
IF DAY > MONTH_END THEN NOP
ELSE DO
DAY = DAY - SUBSTR(CAL,CALC_DAY-3,3)
LEAVE /* DONE WITH CALC_DAY*/
END
MONTH = MONTH+1
END
RETURN CENTURY_YEAR||'/'||MONTH||'/'DAY

I am sure you could hack it around to get the exact format you require.

Hope this helps
 
You'll want to add some editing up front, but the basic process is:
Code:
gyy4 = gyy + (gcc*100)                 /* 4-digit year               */
mct.=0
push    31     x    31    30    31    30    31    31    30     31     30     31
pull mct.1 mct.2 mct.3 mct.4 mct.5 mct.6 mct.7 mct.8 mct.9 mct.10 mct.11 mct.12
mct.2 = 28 + (gyy4//4=0) - (gyy4//100=0) + (gyy4//400=0)
jdd = gdd                              /* initialize                 */

do i = 1 to (gmm-1)
   jdd = jdd + mct.i
end

jul_dt = gyy4||Right(jdd,3,0)
say "G:"greg_dt "= J:"jul_dt
 
Many thanks for your responses - I will try them out.
 
Status
Not open for further replies.

Similar threads

  • Locked
  • Question
Replies
4
Views
400
Replies
3
Views
128

Part and Inventory Search

Sponsor

Back
Top