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

140 pts.
Tags:
AS/400
RPG
RPG/400
How to convert a Date given in Char format to numeric format in RPG of As400..

Answer Wiki

Thanks. We'll let you know when a new response is added.

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.

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    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
    125,585 pointsBadges:
    report
  • Splat
    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.
    7,115 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following