× 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.



If you are on release 6.1 or higher:

Exec SQL
Set :MyNumYYMD = Dec(VarChar_Format(

Timestamp_Format(:MyMDY, 'MM/DD/YYYY'),
'YYYYMMDD'),
8, 0);

Mit freundlichen Grüßen / Best regards

Birgitta Hauser

"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"


-----Ursprüngliche Nachricht-----
Von: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] Im
Auftrag von CRPence
Gesendet: Wednesday, 30.5 2012 18:14
An: rpg400-l@xxxxxxxxxxxx
Betreff: Re: Date Validation

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/rbafzmstch2d
ata.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
--
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.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.