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 to timestamp conversion

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
Join Date: Aug 2004
Posts: 138
date to timestamp conversion

UDB V8.1 fp6a
AIX 5.2

Can any one tell me how to convert a date in the format of MM/DD/YYYY to timestamp format of YYYY-MM-DD HH24:MIS ?

I tried timestamp_format function..unable to get the results I wanted
Reply With Quote
  #2 (permalink)  
Old
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,713
Since you are starting with date and converting to timestamp, I assume the hours, minutes, seconds, etc can be zero.

select char(birthdate, iso)||' 00:00:00.000000' from emp
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #3 (permalink)  
Old
Registered User
 
Join Date: Aug 2004
Posts: 138
Thabks Marcus !! I 'll try it
Reply With Quote
  #4 (permalink)  
Old
Registered User
 
Join Date: Aug 2003
Location: Massachusetts, USA
Posts: 106
Or use timestamp_iso. Example below

values(timestamp_iso(current date))
Reply With Quote
  #5 (permalink)  
Old
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,126
Or use the "TIMESTAMP" cast function with two arguments; this will also allow you to set the time in addition to the date:
Code:
timestamp(current date, '16:11:12')
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
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