Dateadd function

Database
Highlighted
Enthusiast

Dateadd function

i need to extract the current year birthday date.

birthday column is yyyy-mm-dd hh:mm:ss:**bleep** type

SQL:

ThisYearBirthday_Date = Dateadd(year,DATEDiff(year, BirthDate,GETDATE()),BirthDate)

 

TD:

ADD_YEAR (BirthDate, (cast(BirthDate as date)- cast(current_timestamp as date)) )????

 

 

any help please?

3 REPLIES
Senior Apprentice

Re: Dateadd function

There's no ADD_YEAR or SUBTRACT_MONTH, because ADD_MONTHS covers all :-)

Add_Months(BirthDate, Cast((CURRENT_DATE - BirthDate YEAR) AS INT) * 12)

Of course this assumes that BirthDate is correctly defined as DATE, otherwise use CURRENT_TIMESTAMP instead of CURRENT_YEAR,

 

Btw, are both of you working in the same project?

https://community.teradata.com/t5/Database/DateAdd-and-DateDiff-function-in-Teradata/m-p/73886

Enthusiast

Re: Dateadd function

Yes, we work in the same migration project:) And we have a very big luck to have you here!:)))

 

Do you know any conversion tool ?  we used Ispirer - but it's not good at all

Teradata Employee

Re: Dateadd function

Teradata Professional Services uses a proprietary tool called the Teradata Migration Accelerator that automates script and stored procedure conversion as well as data movement from another platform (SQL Server/DB2/Oracle) to Teradata.  Contact your Teradata representative for more information.