Teradata SQL - DATEADD Function Alternative for ADD / Subtract Days or Months

visibility 17,633 access_time 2 years ago languageEnglish

In ANSI SQL, you can use DATEADD function to easily add or subtract days/week/months/years from a date as the following code snippet shows:

SELECT DATEADD(month, 1, '20060830');
SELECT DATEADD(day, -1, '20060831');

However in Teradata this function is not implemented and you can use interval to add or subtract date units from date types.

Code snippets

Add days

select  EmployeeID,Birthday,
Birthday + Interval '2' day
from    TD_MS_SAMPLE_DB.Employee

Subtract days

select  EmployeeID,Birthday,
Birthday - Interval '2' day
from    TD_MS_SAMPLE_DB.Employee;

Add months

select  EmployeeID,Birthday,
Birthday + Interval '3' month
from    TD_MS_SAMPLE_DB.Employee

Subtract months

select  EmployeeID,Birthday,
Birthday - Interval '3' month
from    TD_MS_SAMPLE_DB.Employee
info Last modified by Administrator 2 years ago copyright This page is subject to Site terms.

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

timeline Stats
Page index 22.17
More from Kontext
BigQuery - Convert Bytes to BASE64 or HEX String
visibility 595
thumb_up 0
access_time 9 months ago
BigQuery - Convert Bytes to BASE64 or HEX String
Teradata tdwallet Examples
visibility 1,848
thumb_up 0
access_time 2 years ago