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 > Urgent DB2 date conversion help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-27-07, 14:33
nivasreddy007 nivasreddy007 is offline
Registered User
 
Join Date: Jun 2007
Posts: 66
Urgent DB2 date conversion help

Hi ,

Can you tell me what is wrong with the following expression.I am unable to covert it to the date type.


values DATE(CHAR(CAST((4+1) AS CHAR(2)) || '/01/' || CAST(YEAR(CURRENT_DATE) AS CHAR(4))))
Reply With Quote
  #2 (permalink)  
Old 06-27-07, 15:23
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
It may help if you look at the result of VALUES CHAR(CAST((4+1) AS CHAR(2)) || '/01/' || CAST(YEAR(CURRENT_DATE) AS CHAR(4)))
Reply With Quote
  #3 (permalink)  
Old 06-27-07, 15:28
nivasreddy007 nivasreddy007 is offline
Registered User
 
Join Date: Jun 2007
Posts: 66
'5 /01/2007'


Above is the result for the expression without date function..Any idea why the above result is not taken by DATE function??

Thanks
Reply With Quote
  #4 (permalink)  
Old 06-27-07, 15:48
nivasreddy007 nivasreddy007 is offline
Registered User
 
Join Date: Jun 2007
Posts: 66
I understood the problem now..The day part was defined as char(2) and there was an unwanted space being inserted..Thanks for the reply
Reply With Quote
  #5 (permalink)  
Old 06-29-07, 03:28
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
You can use RTRIM() to get rid of such spaces.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
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