If you want to do EXACTLY what you were doing before, do this:
IsoDate = %date(cmStart: *iso);
MdyDate = %dec(IsoDate: *mdy);
As I hope you can see, it's not all that different from what you were
doing before. The %date() BIF converts a field into a 'date field'.
The %dec() BIF converts a field into a 'decimal' (packed) field.
Note that this doesn't even require free format. For example, you could
do this if for some reason you wanted to do it in fixed format.
Personally, I would much prefer to see this than the MOVE opcode...
C eval IsoDate = %date( cmStart : *iso )
C eval MdyDate = %dec( IsoDate : *mdy )
The problem with MOVE is that it doesn't really explain what it's doing.
With %date() you can tell it's converting to a date. With %dec() you
can tell it's converting to numeric. With MOVE you just don't know, and
have to figure it out from the data types of the variables -- which are
usually not defined nearby. So I like this technique better than MOVE
even in fixed format.
But -- the point is, it does precisely the same as what you were doing,
and I don't really think it's any more confusing.
This, on the other hand, makes it slightly harder to read, but saves you
a line of code:
MdyDate = %dec(%date(cmStart: *iso): *mdy);
This eliminates having to put the output of %date() into a variable, and
then pass that variable to the input of %dec()... it simply uses the
output of %date() directly as the input of %dec().
But, if you find that confusing, you aren't REQUIRED to do it that way.
Whatever the case, avoid using %char() (which converts to character)
which so many folks on this list gave you as an example. That's a bad
habit that started because V5R2 didn't have support for dates in the
%dec() opcode. V5R2 is obsolete now, there's no reason to keep using
that kludge.
On 2/2/2010 2:08 PM, Smith, Mike wrote:
Thanks
This approach worked.
Seems more confusing, but I guess I'll get used to it.
MDYDATE = %dec(%char(ISODATE:*mdy0):6:0); // D'ccyy-mm-dd' to
mmddyy
On Tue, Feb 2, 2010 at 1:10 PM, Smith, Mike
C *ISO Move CMSTART ISODATE
C *MDY Move ISODATE MDYDATE
As an Amazon Associate we earn from qualifying purchases.