×
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.
On 30 May 2012 05:50, Jeff Young wrote:
I have an application that needs to validate and convert a date from
an external system.
The format of the date can be m/d/ccyy,mm/d/ccyy,m/dd/ccyy,mm/dd/ccyy
with the "/" included.
The converted format needs to be a numeric field in the format
ccyymmdd.
I have the following code in my program:
<snip>
// Edit Start Date
Monitor;
EpHOrDate = %Dec(%Date(Start_Date : *USA));
<<SNIP>>
Using the values above, I set Date_In in DEBUG prior to the Monitor
to each of the dates.
BOTH of the dates were flagged as errors.
A. What am I doing wrong?
B. How can I handle the different date formats for editing and
conversion?
The client is on V6R1M1
SQL understands those date formats as valid DATE representations even
though the RPG does not. Other date features, e.g. CEE APIs, probably
handle them fine as well. An SQL expression to assign a 10P00 value
from the date string:
Exec SQL
set :EpHOrDate /* test SQLCODE and\or SQLSTATE for errors */
= dec(replace(char(date(:Start_Date),ISO),'-',''), 10) ;
For reference, this same topic was discussed back in March:
# Subject: Date conversion from m/d/ccyy format
# Date: Thu, 22 Mar 2012 09:30:24 -0400
http://archive.midrange.com/rpg400-l/201203/threads.html#00257
http://archive.midrange.com/rpg400-l/201203/msg00316.html
"...
RPG officially requires that the month and day each have two digits,
with leading zeros if necessary. ... massage the character value so that
it was in mm/dd/yyyy form, and then use %DATE.
... _untested code example was given_ ...
"
http://archive.midrange.com/rpg400-l/201203/msg00323.html
"...
_String representations of datetime values_
http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/db2/rbafzmstch2data.htm#dtstrng
'Leading zeros can be omitted from the month and day portions when using
the IBM® SQL standard formats. Each IBM SQL standard format is
identified by name and includes an associated abbreviation (for use by
the CHAR function).'
"
Regards, Chuck
As an Amazon Associate we earn from qualifying purchases.
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.