Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

RPG Julian Date CODE

1,292 views
Skip to first unread message

Jack Kingsley

unread,
Jul 11, 2002, 7:31:47 AM7/11/02
to
Can someone provide some help on this. I have a field that is in
YYMMDD that is packed 6,0. What can I do to get the date in julian.
Example is 020711.

Hans Boldt

unread,
Jul 11, 2002, 8:35:44 AM7/11/02
to

Here's a V5R2 RPG IV program that converts a numeric date in *YMD
format to a numeric date in *JUL format:

----------------------------------------------------
D date s 6p 0 inz(020711)
/free
date = %dec(%char(%date(date:*ymd):*jul0):6:0);
dsply date;
*inlr = *on;
/end-free
-----------------------------------------------------

The %DATE() built-in converts the numeric date to a data data type.
The next %CHAR() built-in converts the date to character data type
with the date in julian format. Finally, the %DEC() built-in
converts the date back to numeric type. That last step is new for
V5R2. In previous releases, you can use C run-time library function
"atol()" instead, but this also requires you to code a procedure
prototype for "atol()", as well as BNDDIR(QC2LE) on the H-Spec.

(You could probably also do this with a couple of MOVE opcodes, if
you're so inclined.)

Cheers! Hans

Drew Dekreon

unread,
Jul 11, 2002, 9:03:47 PM7/11/02
to
two steps: first, get it into a date field
*ymd0 move yymmdd datefld
second, extract the julian
*jul move datefld target
You might need to use *jul0 instead of *jul
RPG5 has a nicer way to do it, using the new %date() bif
"Jack Kingsley" <jkin...@wmfinance.com> wrote in message
news:ce2fab65.0207...@posting.google.com...
0 new messages