140 pts.
 How to convert a Date given in Char format to numeric format in RPG of As400.
How to convert a Date given in Char format to numeric format in RPG of As400..

Software/Hardware used:
ASKED: June 11, 2008  4:35 AM
UPDATED: April 27, 2010  3:05 PM

Answer Wiki:
EVAL numericField = %dec(%date(alphaDate:*MDY/):*MDY) The parm following the char field must be the format of the char field (I used *MDY with "/"for an example). The parm at the end of the expression must be the format of the numeric field. So this example converts 11/22/2008 to 11222008. If you want 2008-11-22 converted to 20081122 make both parms *ISO. Give an example of what you want and we can be more specific.
Last Wiki Answer Submitted:  June 13, 2008  10:45 pm  by  graybeard52   3,115 pts.
All Answer Wiki Contributors:  graybeard52   3,115 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Why would you convert to Numeric? If it’s a date, then convert to a Date data type instead. (I can guess at least one answer — “Because the file doesn’t define it as a Date. Instead it defines it as Numeric.” Sigh.)

Tom

 110,155 pts.

 

This from a program that updates a (software vendor’s) file:

YYYY   = %SubDt(%Date(InDate: *ISO0): *Years); 
MM     = %SubDt(%Date(InDate: *ISO0): *Months);
DD     = %SubDt(%Date(InDate: *ISO0): *Days); 

The InDate field is character information coming from a fixed format .txt file.

 5,740 pts.