You are right Scott, and I found that just before you responded.....but I
certainly like the last line better ......
Thanks Scott, I appreciate the response....
From:
Scott Klement <rpg400-l@xxxxxxxxxxxxxxxx>
To:
RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx>
Date:
07/01/2008 02:41 PM
Subject:
Re: Having a date conversion issue
Hi Doug,
0101.05 TestDateN = %Dec(%Date(Tsw3:*Cymd):*Iso);
0101.06 TestDateN = %dec(%Date(TestDateN:*cymd)+ %days(1));
Shouldn't that second line have *iso instead of *cymd? You've already
converted the date to *ISO at that point...
I think the "receiver too small" error is coming from the fact that
you're trying to tell the system that an 8,0 date is actually a 7,0
date. So when the %date() BIF tries to read an 8-digit date, the
internal *CYMD can't hold the result. Changing the second line to *ISO
should solve that problem.
However... if you read what your code does (Step-by-step) you'll see
that it does this:
a) read numeric date from file
b) Convert numeric date (cymd) to date field
c) Convert date field to numeric field (iso)
d) convert numeric field (iso) to date field again
e) add a day to date field
f) convert back to numeric field, iso
Wouldn't it be a lot cleaner to convert it to a date once, add a day,
then convert it back to a number? Just one line of code like this:
TestDateN = %Dec(%Date(Tsw3:*Cymd) + %days(1):*Iso);
It just seems simpler... read the number (cymd), make it a date field,
add a day, convert it back to a number (iso).
As an Amazon Associate we earn from qualifying purchases.