Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 10 Feb 2005 @ 09:22:28 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


Subj:   Re: Epoch function
 
From:   Dieter Noeth

Ganga Palakattil wrote:

  I have an absolute time value in milliseconds starting from 1970-01-01 00:00:00. I need to add that absolute time value to the base (1970- 01-01 00:00:00) and want to re-produce the real time-stamp.  



Another way:

     select
        (cast(current_timestamp as date) - date '1970-01-01') * 86400000.
        + (extract(hour from current_timestamp) * 3600000)
        + (extract(minute from current_timestamp) * 60000)
        + cast(extract(second from current_timestamp) * 1000 as int) as millisecs

        ,cast(millisecs / 1000 as int) as secs

        ,cast(date '1970-01-01' + (secs / 86400) as timestamp(3))
        + ((secs mod 86400) / 3600 * interval '1' hour)
        + (((millisecs / 1000.000) mod 3600) * interval '1' second)
     ;

Dieter



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023