× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Thanks for the explanation scott.

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Scott Klement
Sent: Tuesday, February 02, 2010 4:49 PM
To: RPG programming on the IBM i / System i
Subject: Re: Moving *ISO date to *MDY date in Free Format

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

--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing
list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.




NOTICE: This message, including any attachment, is intended as a confidential and privileged communication. If you have received this message in error, or are not the named recipient(s), please immediately notify the sender and delete this message.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.