steve-myers wrote:The "standard" "Julian" (which it isn't, but that's not for this forum!) date is a 6 digit packed decimal value in 4 bytes with the format 0cyydddF, where c is 0 for dates from January 1, 1900 through December 31, 1999, 1 for dates from January 1, 2000 through December 31, 2099, yy is 01 through 99, and ddd is the day of year from 001 to 365 or 366 in a leap year, and F is an alternate packed decimal sign.
I suppose there must be some reason for that
So instead of x'19' it is x'00' and instead of x'20' it is x'01'? Was there some fear that 81 centuries (OK, 80-and-a-bit centuries) wouldn't be enough, so they decided on 10?
Anyway, off the topic.
01 W-JULIAN-DATE-CCYYDDD PIC 9(7). (deliberately with no sign)
01 FILLER REDEFINES W-JULIAN-DATE-CCYYDDD.
05 W-JULIAN-DATE-CCYY PIC 9(4). (again, deliberate)
05 W-JULIAN-DATE-DDD PIC 999. (again).
Moves to the 05. Then move to 01 to a comp-3 pic s9(7) (or pic 9(7) depending on what value you want in the sign, C or F).
If you want the day and year the wrong way round, just swap them in the definition above.
enrico's solutions will achieve the same results. The multiplies just being a means to "shift left" by 3 or 4 bytes respectively.
If you want the "standard", as above, first chop off the century (so PIC 99 for W-JULIAN-DATE-YY). Then move to a comp-3 of pic s9(5) (or 9(5), yaddady, yaddady...). Then, iterrogate the century. If 19, move an X'00', if 20, move an X'01' into field arranged as below.
01 W-JULIAN-DATE-XYYDDD COMP-3 PIC 9(7). (deliberately with no sign)
01 FILLER REDEFINES W-JULIAN-DATE-XYYDDD.
05 W-JULIAN-DATE-X-IND PIC X.
05 W-JULIAN-DATE-YYDDD COMP-3 PIC 9(5). (again, deliberate)