View previous topic :: View next topic |
Author |
Message |
yadav2005 Intermediate
Joined: 10 Jan 2005 Posts: 348 Topics: 144
|
Posted: Wed Mar 07, 2007 2:21 am Post subject: Gregorian Date to Julian date in DB2 |
|
|
Hai,
I want to convert DB2 date which is present in a table into it's equivalent Julian Date using a query and i want to display it.
INPUT
OUTPUT EXPECTED
|
|
Back to top |
|
|
bauer Intermediate
Joined: 10 Oct 2003 Posts: 315 Topics: 49 Location: Germany
|
Posted: Wed Mar 07, 2007 5:03 am Post subject: |
|
|
yadav2005,
try this:
Code: |
SELECT JULIAN_DAY('2007-03-07')
FROM SYSIBM.SYSDUMMY1;
---------+---------+---------+---------+---------+---------+----
---------+---------+---------+---------+---------+---------+----
2454167
DSNE610I NUMBER OF ROWS DISPLAYED IS 1
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
|
The base day of this DB2 function is 1. January 4712 BC.
Your base day seems to be a different one. Julian date depends always on the base day.
regards
bauer |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Wed Mar 07, 2007 5:51 am Post subject: |
|
|
yadav2005,
You are looking for DAYOFYEAR function in sql. The DAYOFYEAR function returns an integer in the range of 1 to 366 that represents the day of the year where 1 is January 1.
Code: |
SELECT DAYOFYEAR('2007-03-07')
FROM SYSIBM.SYSDUMMY1
;
|
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
yadav2005 Intermediate
Joined: 10 Jan 2005 Posts: 348 Topics: 144
|
Posted: Wed Mar 07, 2007 6:29 am Post subject: |
|
|
Thanks Kolusu and Bauer for your replies and it has helped me. |
|
Back to top |
|
|
|
|