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 > Db2 - convert timestamp to Date and time

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-23-11, 08:31
AcC8braman AcC8braman is offline
Registered User
 
Join Date: Jun 2011
Posts: 3
Db2 - convert timestamp to Date and time

Hi All,

I am having problems trying to convert a timestamp in milleseconds to date and time.

This is what I have been trying but it doen't like the format :-

WHEN JST_JOB_STREAMS.JST_START_OFFSET <> -1 THEN to_char (to_date(mod(round(JST_JOB_STREAMS.JST_START_OFFSE T/1000),86400), 'SSSSS' ), 'HH24:MIS')

Thanks in advance

Steve
Reply With Quote
  #2 (permalink)  
Old 06-23-11, 08:40
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Rather than showing an attempted solution that does not work, it might make more sense to tell us what you have as the input and what you want as the output...
Reply With Quote
  #3 (permalink)  
Old 06-23-11, 08:46
AcC8braman AcC8braman is offline
Registered User
 
Join Date: Jun 2011
Posts: 3
Good point

I have a timestamp field that is displayed in milliseconds that I need converting to human readable format to HH24:MIS

This is an example of what is stored in the field :79200000

Thanks

Steve
Reply With Quote
  #4 (permalink)  
Old 06-23-11, 08:57
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally Posted by AcC8braman View Post
a timestamp field that is displayed in milliseconds
Milliseconds since what? Epoch? Midnight? Jan. 1st?
Reply With Quote
  #5 (permalink)  
Old 06-23-11, 09:13
tonkuma tonkuma is online now
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
Quote:
...HH24:MIS
Then it must be time data type, not the timestamp data type.

If convert miliseconds to time,
try
TIME('00:00:00') + (79200000 / 1000) SECONDS
Reply With Quote
  #6 (permalink)  
Old 06-23-11, 09:24
AcC8braman AcC8braman is offline
Registered User
 
Join Date: Jun 2011
Posts: 3
Excellent, that worked a treat

I think the first one was used for an Oracle DB so that's why it wasn't working.

Thanks for your help peeps
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