Link to home
Start Free TrialLog in
Avatar of roosterup
roosterup

asked on

AS400 Convert text date field in mm/dd/yyyy format and store as a date field

I need to check a 10 digit text field for a valid date, then store the date in a date type field. what's the best why to do this in rpg?
ASKER CERTIFIED SOLUTION
Avatar of Gary Patterson, CISSP
Gary Patterson, CISSP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of roosterup
roosterup

ASKER

I decided to use test(de) but I assume your solution would work.  any advice on the easiest way to test for future dates or ridiculously old dates?
// To test for a future date:
if myDate > %date();
... do something here
endif;

// To test for a date prior to Jan 1, 1900, assuming DATFMT is set to ISO.
d riduculouslyOldDate...
d                                 c                       const(d'1900-01-01')
if myDate < ridiculouslyOldDate;
... do something here
endif;
How "well formed" are the dates? I.e., will they always be MM/DD/YYYY? Or is "1/7/2015" valid?