IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to format dates from 'yyyy-mm-dd'


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vardhan0007

New User


Joined: 05 Jun 2006
Posts: 51
Location: Bangalore,India

PostPosted: Wed Aug 08, 2007 3:25 pm
Reply with quote

Hi,

I want to foramt date from 'yyyy-mm-dd' to either 'mmyydd' or 'ddmmyy'
or to julian date. CAn someone assist me onthis how to format the date.

Thanks in advance

Harsha.
Back to top
View user's profile Send private message
Prajesh_v_p

Active User


Joined: 24 May 2006
Posts: 133
Location: India

PostPosted: Wed Aug 08, 2007 5:07 pm
Reply with quote

Usually you can use abbreviations like ISO USA EAU etc to reformat the dates.
IBM European standard EUR dd.mm.yyyy 12.10.1987..
CHAR(YOUR_DATE,EUR)

If the dot is not a problem, u can use this formating

To make it exactly as what you said..you can use the below code
SELECT SUBSTR(CHAR(YOUR_DATE),6,2)||SUBSTR(CHAR(YOUR_DATE),3,2)||SUBSTR(CHAR(YOUR_DATE),9,2) FROM ....

Thanks,
Prajesh
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 355
Location: New York

PostPosted: Wed Aug 08, 2007 5:23 pm
Reply with quote

Do you want to do with SQL query or COBOL program?

With COBOL program, it is simple.

Just do reference modification to change 'yyyy-mm-dd' to either 'mmyydd' or 'ddmmyy'. during this ignore the positions of hyphens.

E.g., 07-08-2007 to 07082007

MOVE first-date(1:2) to second-date(1:2)
MOVE first-date(4:2) to second-date(3:2)
MOVE first-date(7:4) to second-date(5:4)

In the same way you can do for other format.

Reagrds,
KSK
Back to top
View user's profile Send private message
vardhan0007

New User


Joined: 05 Jun 2006
Posts: 51
Location: Bangalore,India

PostPosted: Wed Aug 08, 2007 5:37 pm
Reply with quote

No i dont wan to use cbol program. While selecting the date from data base i need to format it in query..

ksk wrote:
Do you want to do with SQL query or COBOL program?

With COBOL program, it is simple.

Just do reference modification to change 'yyyy-mm-dd' to either 'mmyydd' or 'ddmmyy'. during this ignore the positions of hyphens.

E.g., 07-08-2007 to 07082007

MOVE first-date(1:2) to second-date(1:2)
MOVE first-date(4:2) to second-date(3:2)
MOVE first-date(7:4) to second-date(5:4)

In the same way you can do for other format.

Reagrds,
KSK
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Wed Aug 08, 2007 6:00 pm
Reply with quote

vardhan0007 wrote:
No i dont wan to use cbol program. While selecting the date from data base i need to format it in query..

ksk wrote:
Do you want to do with SQL query or COBOL program?

With COBOL program, it is simple.

Just do reference modification to change 'yyyy-mm-dd' to either 'mmyydd' or 'ddmmyy'. during this ignore the positions of hyphens.

E.g., 07-08-2007 to 07082007

MOVE first-date(1:2) to second-date(1:2)
MOVE first-date(4:2) to second-date(3:2)
MOVE first-date(7:4) to second-date(5:4)

In the same way you can do for other format.

Reagrds,
KSK


You need to use the CHAR and SUBSTR functions and concatenate to get what you want. For the Julian date you will need the DAYOFYEAR function.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts InfoSphere OPTIM CSV ouput vs DSNTIUA... IBM Tools 3
No new posts Need mmmyy date format SYNCSORT 6
Search our Forums:

Back to Top