Just to add to what Jon said, I see a lot of confusion about the %date(field: format) and %char(date-field: format). They look the same, but the format identifier means slightly different things. In the %date() function, format tells the BIF the format of the date in field, but in the %char() function (and also in %dec), the format tells the format of the output date value. Maybe the real confusion is in the fact that none of the format identifiers tells the system how to store a date-field internally. Instead it tells the format of the value in a non-date field. This is because, to state the obvious, a value in a date field represents exactly one date, and every possible date has a unique representation in that date field. However, in a numeric or character field, there are a number of ways to represent January 1, 2010, and the value 100101 can represent a number of dates. Hence the need for a date format identifier.
The way I get around the confusion is to think of the internal date format of date and timestamp fields as always *ISO (even though it may be something different). I document that with ctl-opt DatFmt(*ISO); Then I define all of my constants and initializers in *iso format (d'0001-01-01'). When I move a date to a character or number field, I always explicitly specify the output format (that is the format I want the number or character value to appear as) in the %char or %dec function. When I move a number or character field to a date field, I always explicitly specify the input format (that is the format of the date value in the character or number field) in the %date function.
Mark Murphy
STAR BASE Consulting, Inc.
mmurphy@xxxxxxxxxxxxxxx
-----"Vidal, Peter" <Peter.Vidal@xxxxxxxxxxxxxxx> wrote: -----
To: Midrange - RPG <rpg400-l@xxxxxxxxxxxx>
From: "Vidal, Peter" <Peter.Vidal@xxxxxxxxxxxxxxx>
Date: 03/11/2016 10:34AM
Subject: What is wrong with this %DATE function
Hi list!
DPA_F55EOPR S 10A Inz('20110101 ')
DMinDteCR S D DatFMT(*USA)
/free
MinDteCR = %Date((PA_F55EOPR):*USA);
*inlr = *on;
/end-free
It is blowing up with this error: Date, Time or Timestamp value is not valid (C G D F).
TIA,
Peter Vidal
Developer AS400
P: 800-808-1902, x137210 | F: 813-884-2847
9119 Corporate Lake Dr., Suite 300 | Tampa, FL 33634 | www.carecentrix.com<
http://www.carecentrix.com/>
[cid:image001.png@01D17B81.7B648D40]
________________________________
This communication is intended only for the use of the individual or entity named as the addressee. It may contain information which is privileged and/or confidential under applicable law. If you are not the intended recipient or such recipient's employee or agent, you are hereby notified that any dissemination, copy or disclosure of this communication is strictly prohibited. If you have received this communication in error, please immediately notify CareCentrix Compliance Hot Line at (877) 848-8229 and notify the sender by electronic mail. Please expunge this communication without making any copies. Thank you for your cooperation.
As an Amazon Associate we earn from qualifying purchases.