Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 06 Jul 2006 @ 21:07:37 GMT


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


Subj:   Error with timestamp calculation
 
From:   Flavio Sobral

Hi All,

Could someone help me with this timestamp issue ?

Submitting this query from queryman (sql assistant) I get the following results:

     select z.x
           ,z.x + cast ('000 00:00:00.000009' as interval day(4) to second(6)) A
           ,z.x - cast ('000 00:00:00.000009' as interval day(4) to second(6)) B
           ,z.x - cast ('000 00:00:01.999999' as interval day(4) to second(6)) H
     from
          (
           select cast ('2000-12-31 00:00:00.000000+00:00' as timestamp(6) with time zone  ) X
           )   Z

Results:

     X = 2000-12-31 00:00:00.000000+00:00
     A = 2000-12-31 00:00:00.000009+00:00
     B = 2000-12-31 00:00:00.000009+00:00               <-----WRONG
     H = 2000-12-30 23:59:58.000001+00:00

Columns X, A and H are ok, but why column B is wrong ?

When I run the same query using bteq, I get the error message '7451 invalid timestamp'.

If I remove the column B from the query, like this:

     select z.x
        ,z.x + cast ('000 00:00:00.000009' as interval day(4) to second(6))
     A
        --,z.x -  cast ('000 00:00:00.000009' as interval day(4) to second(6)) B
        ,z.x -  cast ('000 00:00:01.999999' as interval day(4) to second(6))
     H from
          (
           select cast ('2000-12-31 00:00:00.000000+00:00' as timestamp(6) with time zone  ) X
           )   Z

Then the results are OK. I mean, column X, A and H are OK.


Questions:

1 - Why I get different results from queryman and bteq ?

2 - How can I subtract '000 00:00:00.000001' from a timestamp ?


Please Help !

Thanks in advance,

Flavio Sobral



     
  <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