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
 
Julian to gregorian convertion with sql query

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
Lenzbanu

New User


Joined: 08 Mar 2005
Posts: 2

PostPosted: Wed Jul 08, 2009 10:28 am    Post subject: Julian to gregorian convertion with sql query
Reply with quote

can anyone suggest me how to make Julian to gregorian conversion with sql query and vice versa.
Back to top
View user's profile Send private message

Lenzbanu

New User


Joined: 08 Mar 2005
Posts: 2

PostPosted: Wed Jul 08, 2009 11:00 am    Post subject: Reply to: Julian to gregorian convertion with sql query
Reply with quote

To convert from gregorian to julian date, i tried the following
select date('2009-01-01') as dt,
year('2009-01-01') * 1000 + dayofyear('2009-01-01') as dt1
from temp1;

require suggestion?
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1243
Location: Israel

PostPosted: Wed Jul 08, 2009 3:21 pm    Post subject:
Reply with quote

Don't know about better/other solutions, but that does the work:
Code:
SELECT DATE('2009-07-08') AS DT,                         
YEAR('2009-07-08') * 1000 + DAYOFYEAR('2009-07-08') AS DT1
FROM SYSIBM.SYSDUMMY1


Ketan Varhade wrote:
This save the MIPS
Forget about the MIPS, better save the whales!
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Wed Jul 08, 2009 3:27 pm    Post subject:
Reply with quote

a date can be generated by adding the julian DDD - 1 to Jan, 01 of the julian YY.

a julian date can be generated by using the difference in days - 1 between a date and Jan 01 of the year

marso, you posted while I was composing. yours is a better solution,
Back to top
View user's profile Send private message
Ketan Varhade

Active User


Joined: 29 Jun 2009
Posts: 197
Location: Mumbai

PostPosted: Wed Jul 08, 2009 3:27 pm    Post subject:
Reply with quote

Hi Marso,
This query wont be dynamic and needs to be changed every time. If the requirement is to run on the SPUFI,QMF then fine but for runing in the embeded COBOL-DB2 then the above mentioned logic can be right.

Correct me if I am wrong.

Thanks
Ketan Varhade
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Wed Jul 08, 2009 3:30 pm    Post subject:
Reply with quote

Ketan Varhade
replace the hardcoded date with a host variable containing a db2 date datatype value.

you have been corrected.
Back to top
View user's profile Send private message
Ketan Varhade

Active User


Joined: 29 Jun 2009
Posts: 197
Location: Mumbai

PostPosted: Wed Jul 08, 2009 3:36 pm    Post subject:
Reply with quote

Thanks
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1243
Location: Israel

PostPosted: Wed Jul 08, 2009 5:15 pm    Post subject: Reply to: Julian to gregorian convertion with sql query
Reply with quote

Lenzbanu provided both question and answer from the beginning.
I did nothing but correct the FROM, run it under QMF and check the result.

Quote:
replace the hardcoded date with a host variable
that should have been obvious to everybody.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Wed Jul 08, 2009 5:28 pm    Post subject:
Reply with quote

Quote:
that should have been obvious to everybody


Marso, you forget where you are.
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 HEX value search in a DB2 query maxsubrat DB2 2 Wed Oct 04, 2017 3:04 pm
No new posts Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
No new posts Julian Date to CICS ABSTTIME blayek CICS 3 Wed Aug 30, 2017 11:15 pm
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am
No new posts Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am

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