Try to trim off leading and trailing *Blanks.
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 Jeff Young
Gesendet: Wednesday, 30.5 2012 14:51
An: rpg400-l@xxxxxxxxxxxx
Betreff: Date Validation
All,
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));
On-Error;
Load_Exception ('Start date is not a valid date');
EndMon;
// Edit Invoice Date
Monitor;
EpHInDate = %Dec(%Date(Invoice_Date : *USA));
On-Error;
Load_Exception('Invoice date is not a valid date');
EndMon;
</snip>
Where Start_Date and Invoice_Date are defined as 256A Varying and EpHOrDate
and EpHInDate are defined as 8p 0.
For values of 5/7/2012 for order date and 5/14/2012 for invoice date, the
code above rejects the order date, but accepts the invoice date.
I created a small test program to check the date editing process.
H Debug
D Date_in S 256A Varying
D Date_Out S 8 0
D Err S N
/Free
Monitor;
Date_Out = %Dec(%Date(Date_In : *USA));
On-Error;
Err = *On;
EndMon;
Return;
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
Thanks,
--
Jeff Young
Sr. Programmer Analyst
--
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.