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 convert month string into date

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-12-07, 09:50
Yukke Yukke is offline
Registered User
 
Join Date: Jul 2006
Posts: 13
How to convert month string into date

I want to take a string representation of month and convert it to a date format.

For example:
'July' -> '2007-07-01 00:00:00.0'

Thanks
Reply With Quote
  #2 (permalink)  
Old 10-12-07, 12:56
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
You will have to write your own UDF.

Andy
Reply With Quote
  #3 (permalink)  
Old 10-14-07, 13:18
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
Suppose your string repr. of month name is in "month_name"; then
Code:
VALUES(
 CASE month_name
  WHEN 'July' THEN DATE('2007-07-01')
  WHEN 'January' THEN ...
  WHEN ...
  ...
  ELSE CAST(NULL AS DATE)
 END)
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/

Last edited by Peter.Vanroose; 10-14-07 at 14:33.
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