Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Fri, 29 Feb 2008 @ 18:06:42 GMT


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


Subj:   Re: Char to date in teradata
 
From:   Curley, David

Hi Gagan,

1) In Oracle, why not just use trunc(end_date,'year') -1? That's a lot clearer than casting and concatenating.

2) In Teradata, you can use Michael Larkins' approach (which is a pretty good rule of thumb, by the way) or you can do it with math.

If you're just inserting and formatting for output doesn't matter, you can use

     (current_date/10000 -1) * 10000 + 1231

If you want it look like a date in a report:

     cast((current_date/10000 -1) * 10000 + 1231 as date)

You can add (format 'dd-mmm-yyyy') if you don't want to use your system's default format.

3) You might be getting the invalid date because there's no dash after "dec." So your concatenation gives you "31-dec2007" instead of "31-dec- 2007."


Dave



     
  <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