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 > date operator

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-14-03, 01:20
krajkumar6 krajkumar6 is offline
Registered User
 
Join Date: Sep 2003
Posts: 9
date operator

hi,

When I issued the SQL,


SELECT DATE(02003082) FROM tab1

inorder to display the date 2003-08-22,db2 gave me the date

5485-04-02.

I am not able to deduce how db2 is doing this conversion.
Can someone tell me how exactly db2 gives me this answer?

Thanks,
K Rajkumar
Reply With Quote
  #2 (permalink)  
Old 10-14-03, 01:30
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
Do you mean:

SELECT DATE(20030822) FROM tab1?
Reply With Quote
  #3 (permalink)  
Old 10-14-03, 01:35
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
If the argument is a number:
– The result is the date that is n-1 days after January 1, 0001, where n is
the integral part of the number.

So when you say SELECT DATE(02003082) FROM tab1
it is 2,003,082 days or 5485 years after 01-01-001.

Maybe you should select SELECT '2003-08-22' FROM tab1
Reply With Quote
  #4 (permalink)  
Old 10-14-03, 01:35
krajkumar6 krajkumar6 is offline
Registered User
 
Join Date: Sep 2003
Posts: 9
That was the actual intended statement.
But since db2 gave an error saying that the date
was not in the permissible range,I tried

DATE(02003082) instead of DATE(20030822) .

But I was not able to understand the conversion.


regards,
K Rajkumar
Reply With Quote
  #5 (permalink)  
Old 10-14-03, 01:46
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
DB2 will not accept 'SELECT DATE(20030822) from Table1'
becasue it is not Y10K ready (when the world will come to an end).
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