TIMESTAMP to DATFMT(*USA) conversion in RPGLE.

pts.
Tags:
Development
I have a character field in a physical file that is defined as: A TSTAMP 26 I need to display the date portion of this field in DATFMT(*USA) form on my display. an example of its contents is 2005-03-04-11.12.21.395000 Can anyone give me a free-form algorithm to place the date portion of this field in a field defined with the date format DATFMT(*USA)?

Answer Wiki

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

D DsplyField S D DatFmt(*USA)

/free
DsplyField = %date(%subst(TSTAMP:1:10):*ISO);
/end-free

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
  • Youngrpgnerd
    Use the %date BIF DateField = %date(%subst(charfield(1:10):*ISO); This should be real close.
    0 pointsBadges:
    report
  • Rchevalier
    There is no need to convert the timestamp value before extracting the date portion. You can simply use the %Date() BIF. If your display field is a date data type it would be: DisplayDate = %Date(Timestamp) The %Date BIF always returns the date in *ISO format but the compiler will handle the conversion to *USA for your display file if it is defined as *USA. If the displa field isn't defined as a date data type you will have to add an additional step to convert it from *ISO to *USA. DisplayDate = %Dec(%Date(Timestamp) :*USA) // For V5R3
    0 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