View previous topic :: View next topic
|
Author |
Message |
vardhan0007
New User
Joined: 05 Jun 2006 Posts: 51 Location: Bangalore,India
|
|
|
|
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 |
|
|
Prajesh_v_p
Active User
Joined: 24 May 2006 Posts: 133 Location: India
|
|
|
|
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 |
|
|
ksk
Active User
Joined: 08 Jun 2006 Posts: 355 Location: New York
|
|
|
|
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 |
|
|
vardhan0007
New User
Joined: 05 Jun 2006 Posts: 51 Location: Bangalore,India
|
|
|
|
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 |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
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 |
|
|
|