If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > How to get a running date in DB2 UDB 7.2

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-28-05, 07:00
act7656 act7656 is offline
Registered User
 
Join Date: Mar 2004
Posts: 24
Question How to get a running date in DB2 UDB 7.2

Hi,

What is the fastest way on creating a table with a single column called 'D_date' which contain certain year range .

If i specify i need a 2004 data, the data in this table wil be someting like this:

D_date
2004-01-01, 2004-01-02, ........................................... 2004-12-31


If i specify i need a 2005 data, the data in this table wil be someting like this:
D_date
2005-01-01, 2005-01-02, ........................................... 2005-12-31
__________________
Hello
Reply With Quote
  #2 (permalink)  
Old 02-28-05, 09:23
urquel urquel is offline
Registered User
 
Join Date: Aug 2004
Posts: 330
Can you tell us why you need a table like this?
Reply With Quote
  #3 (permalink)  
Old 02-28-05, 10:04
act7656 act7656 is offline
Registered User
 
Join Date: Mar 2004
Posts: 24
to get a calendar table for generating trading day on the stock exchange which exclude saturday, sunday n holiday, so tis table is my based table to achieve this objective.
__________________
Hello
Reply With Quote
  #4 (permalink)  
Old 02-28-05, 10:10
Wim Wim is offline
Registered User
 
Join Date: Nov 2004
Posts: 1,279
This recursive SQL should work. You can replace 2005 with a host variable.
Code:
WITH temp (da_year) AS
(VALUES DATE(RTRIM(CHAR(2005)) || '-01-01')
UNION ALL
SELECT da_year + 1 DAY
FROM temp
WHERE da_year + 1 DAY < DATE(RTRIM(CHAR(2005 + 1)) || '-01-01')
)
SELECT *
FROM temp
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On