Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 14 Feb 2001 @ 16:37:24 GMT


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


Subj:   Re: Datediff function
 
From:   Geoffrey Rommel

David has correctly explained the way dates are stored in Teradata. But what is the datediff function? This is not a built-in Perl function, so it must be either (a) a function in a Perl module (perhaps in DBD::Teradata?) or (b) something you're trying to use in your WHERE clause. If (a), consult the POD for the module you're using. If (b), I'm not aware of any such function in Teradata, although there is one in SQL Server.

If you want to select only certain dates in your WHERE clause, I recommend taking one of two approaches:

1. The true-blue Teradata syntax, in which you use the internal form that David explained and treat them as integers. For instance:

     where glorious_day between 1010101 and 1010131  /* between 1/1/2001 and 1/31/2001 */
     where glorious_day > 1001231  /* after 12/31/2000 */
     where glorious_day = 1010214  /* on 2/14/2001 */

2. ANSI syntax, in which you must use the keyword DATE followed by a date in ANSI form. I think this approach is easier to read, so I prefer it. For instance:

     where glorious_day between date '2001-01-01' and date '2001-01-31'
     where glorious_day > date '2000-12-31'
     where glorious_day = date '2001-02-14'


     
  <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