Teradata Date manipulation


Teradata Date manipulation

It seems like the biggest difference between Databases is the syntax for Date manipulation. I need to filter data based on the "end of the previous year" and the "end of the current month of the previous year". Any help would be appreciated. I have unable to locate a good source defining the syntax for the proposed date manipulation.

Re: Teradata Date manipulation

The Data Types and Literals manual has some useful info on this. Chaptewr 4 covers dates.
A date is held internally as (yyyy-1900)mmdd in an integer.
So 2009-12-17 is held as 1091217.
To get last day date of the previous year, set the month and day to 1st Jan and subtract one.

So end of the previous year is:

Select ((((Current_Date/10000)*10000)+0101) (Date)) - 1;

End of the current month of previous year is:

Select ((((Current_Date/100)*100)+01) (Date)) - 1;