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 > very urgent Plz provide solution ASP

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-19-09, 10:08
raj0390 raj0390 is offline
Registered User
 
Join Date: May 2009
Posts: 3
very urgent Plz provide solution ASP

hello all,

i have a string 'Apr 19 20:00:03 CDT 2009' which i need to convert in to date does DB2 have any function to do it?
Reply With Quote
  #2 (permalink)  
Old 05-19-09, 12:10
Stealth_DBA Stealth_DBA is offline
Registered User
 
Join Date: May 2009
Posts: 472
raj0390, It would help if you list the DB2 and version (along with operating system) so the appropriate answer can be supplied (i.e. some functions are in DB2 z/OS but not LUW).

However, I don't believe any DB2 has a function to convert that string into a Timestamp. At least not directly.

If you format is identical in all cases, you can try to parse out the information and build a timestamp string. For example

SUBSTR('TS-STRING',21,4) || '-' || CASE SUBSTR('TS-STRING',1,3) WHEN 'Jan' THEN '01'
WHEN 'Feb' THEN 02
etc.
end
|| '-' || SUBSR(you get the idea I hope).

PS TS-STRING is the character timestamp string you have in your post. I didn't want to type all that in the example.
Reply With Quote
  #3 (permalink)  
Old 05-19-09, 17:20
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
You should also tell us whether you need a timestamp or a date value.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #4 (permalink)  
Old 05-20-09, 01:32
raj0390 raj0390 is offline
Registered User
 
Join Date: May 2009
Posts: 3
very urgent Plz provide solution ASP

i just need the date value
Reply With Quote
  #5 (permalink)  
Old 05-20-09, 02:47
raj0390 raj0390 is offline
Registered User
 
Join Date: May 2009
Posts: 3
Quote:
Originally Posted by Stealth_DBA
raj0390, It would help if you list the DB2 and version (along with operating system) so the appropriate answer can be supplied (i.e. some functions are in DB2 z/OS but not LUW).

However, I don't believe any DB2 has a function to convert that string into a Timestamp. At least not directly.

If you format is identical in all cases, you can try to parse out the information and build a timestamp string. For example

SUBSTR('TS-STRING',21,4) || '-' || CASE SUBSTR('TS-STRING',1,3) WHEN 'Jan' THEN '01'
WHEN 'Feb' THEN 02
etc.
end
|| '-' || SUBSR(you get the idea I hope).

PS TS-STRING is the character timestamp string you have in your post. I didn't want to type all that in the example.


thx mate, for your time
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