AS/400 date format

35 pts.
Tags:
AS/400 date format
AS/400 Fields
AS/400 queries
How do format a date field to MM/DD/YYYY?

Answer Wiki

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

Yes , this question is regarding using iSeries Query option to format a date field. The field length is somehow 7 e.g 2,021,001 means 2002/10/01 in MM/DD/YYYY format. I cannot figure out how to use the option of “Define Result Field” to format this date field to MM/DD/YYYY format.

Waiting to hear from anyone.

Thank you

Regards,
Zanib

Hi,

Normally 7 long date fields are in the format CYYMMDD, where C=0 means year = 19xx and C=1 means year is 20xx. So 2002/10/01 would be 1021001. To convert this in query you could do the following :-

<pre>
Field Expression Column Heading Len Dec
YMD DATFLD + 19000000 8 0

DDMMYYYY SUBSTR(DIGITS(YMD), 7, 2)||’/’
|| SUBSTR(DIGITS(YMD), 6, 2)||
‘/’||SUBSTR(DIGITS(YMD), 1, 4)
</pre>

If your date has 2 for the century, then you may need to change this slightly.

Regards,

Martin Gilbert.

Hi,

use the keyword DATFMT(*USA) in the dspec during ur date field declaration.

regards,
Murali.S

/////////////////////
Hi,

– This will depend on how the date is currently formatted, but for an example we’ll assume that the date is currently YYYYMMDD format. To convert it to DD/MM/YYYY format :- – +
– <pre> +
– Field Expression Column Heading Len Dec +
– DDMMYYYY SUBSTR(DIGITS(DATFLD), 7, 2)||’/’ +
– ||SUBSTR(DIGITS(DATFLD), 5, 2)|| +
– ‘/’||SUBSTR(DIGITS(DATFLD), 1, 4) +
– </pre> +
– +
– Regards, +

– Martin Gilbert.
//////////////////////////////////////////
It’s a date type and you want to format it *USA – for what purpose? Is the result another date field?
Display, report,
D DateUSA D datfmt(*USA)
D DateISO D datfmt(*ISO)

Eval DateUSA = DateISO

Phil

/////////////////////////

Guys,

I thought this was a question about Query?

Regards,

Martin Gilbert.
///////////////////////
Phil says
Disregard my answer… not a valid response to your need.
Phil

Discuss This Question:  

 
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

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