AS/400 date format
35 pts.
0
Q:
AS/400 date format
How do format a date field to MM/DD/YYYY?
ASKED: Apr 15 2009  1:57 PM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
24530 pts.
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
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 :-


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)


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 :- - +
-
 +  
- Field Expression Column Heading Len Dec +
- DDMMYYYY SUBSTR(DIGITS(DATFLD), 7, 2)||'/' +
- ||SUBSTR(DIGITS(DATFLD), 5, 2)|| +
- '/'||SUBSTR(DIGITS(DATFLD), 1, 4) +
-
+
- +
- 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
Last Answered: Apr 16 2009  4:32 PM GMT by Philpl1jb   24530 pts.
Latest Contributors: Gilly400   23625 pts., ZSID   35 pts., Smurali86   25 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



0