Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How to format dates from 'yyyy-mm-dd'

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: How to format dates from 'yyyy-mm-dd'
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    Post subject:
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: 356
Location: New York

PostPosted: Wed Aug 08, 2007 5:23 pm    Post subject:
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Fetch Previous month & year in MM... girishb2 DFSORT/ICETOOL 3 Thu Sep 21, 2017 9:54 pm
No new posts Convert rows and column into JSON for... Dinesh Manivannan DB2 2 Sun Sep 03, 2017 6:50 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts FTP data transfer from PC to Mainfram... AJAYREDDY All Other Mainframe Topics 8 Wed Aug 23, 2017 9:59 pm
No new posts Need to write record of PS File in ex... Chandan1993 JCL & VSAM 1 Wed Jun 07, 2017 1:35 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us