Convert time stamp to dd/mm/yy

2505 pts.
Tags:
AS/400
AS/400 date format
RPG
How can I convert a timestamp field(declared with type 'Z' in database) to dd/mm/yy format in RPG?

Software/Hardware used:
AS400

Answer Wiki

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

Discuss This Question: 4  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
  • philpl1jb
    When you say RPG do you mean RPGLE(RPG IV)? When you say to dd/mm/yy format - do you mean - convert it to a date type field? - convert it to a char field ? - convert it to a numeric field?
    51,365 pointsBadges:
    report
  • CharlieBrowne
    Yes, it can be done, but I do not believe it can be done with a single siomple instruction If this is something that is going to be done quite often, IO would create a procedure to call, rather than coding someing in one or more programs. Do you need to individual stemps to do this?
    41,430 pointsBadges:
    report
  • WaltZ400
    Here I am assuming you are talking RPGLE. Use the %DATE built in function with format of %DATE(TIMSTAMPFLD) replacing the name in the parantheses with your timestamp field name. If you are writing this to another a field in another file defined as a date field, you can do a 'datefld = %DATE(TIMSTAMPFLD)' right into the field. If you want to display this on a display file or printer file, define the date field you want to move this to with DATFMT(*DMY). If you ever want to do this with the time in the time stamp field, do %TIME(TIMSTAMPFLD) and put it to a field defined in what ever time format you want. The ILE RPG reference guide lists all available date and time formats as well as all of the handy built in functions that you might need in the future.
    655 pointsBadges:
    report
  • TomLiotta
    The only times this should be done is when you want to display or print a TIMESTAMP variable as a DATE value. Otherwise it makes no sense to say "dd/mm/yy format". The format is only for human eyes to read, not for internal use in program logic or storage in a file. . Of course, there are exceptions when working with files created before DATE, TIME and TIMESTAMP data types were available. But new normal code should have no need for such a conversion. You mostly just extract the date portion into a DATE variable and use the job's DATFMT() to do any formatting. . Tom
    125,585 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