Wednesday, June 13, 2007

Convert date into numeric format - RPG free

StrDt is a date field into which a date is being updated. PlHBeg is a julian date in the form yyyyddd.

The code block - %SubSt(%Char(PlHBeg - 1900000):2) gets us the Julian date that is recognized by i5.

StrDt = %Date(%SubSt(%Char(PlHBeg - 1900000):2):*Jul0);

PxHBeg is an 8 digit numeric field into which we are trying to feed a date in Iso (yyyymmdd) format. We use the built in function SubDt to extract each portion of the date and with some basic calculations, we have the date converted to numeric form.

PxHBeg = %SubDt(StrDt:*Y) * 10000 + %SubDt(StrDt:*M) * 100
+ %SubDt(StrDt:*D);

No comments: