MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Gregorian Date to Julian date in DB2

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
yadav2005
Intermediate


Joined: 10 Jan 2005
Posts: 348
Topics: 144

PostPosted: Wed Mar 07, 2007 2:21 am    Post subject: Gregorian Date to Julian date in DB2 Reply with quote

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
Code:

2007-03-07

OUTPUT EXPECTED
Code:

07066
Back to top
View user's profile Send private message
bauer
Intermediate


Joined: 10 Oct 2003
Posts: 315
Topics: 49
Location: Germany

PostPosted: Wed Mar 07, 2007 5:03 am    Post subject: Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Wed Mar 07, 2007 5:51 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
yadav2005
Intermediate


Joined: 10 Jan 2005
Posts: 348
Topics: 144

PostPosted: Wed Mar 07, 2007 6:29 am    Post subject: Reply with quote

Thanks Kolusu and Bauer for your replies and it has helped me.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group