Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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 How to pick only YYMMDD from DATE1P (... atulbaviskar SYNCSORT 7 Wed Mar 22, 2017 11:39 am
No new posts Date and time format in CICS Chandru3183 CICS 2 Sat Mar 18, 2017 12:46 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am
No new posts output data in CSV Format janmejay COBOL Programming 8 Sat Oct 15, 2016 2:20 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us