DATEADD
Description
Increments a DATE, TIME, TIMETZ, or TIMESTAMP value by a specified interval.
The DATEADD
function in Amazon Redshift adds a specified time interval to a date or timestamp. Where datepart
is the type of interval (like 'day' or 'month'), interval
is the number of units to add (positive or negative), and date
is the original date.
Valid datepart
in Snowflake for DATEADD
:
microsecond, microseconds
millisecond, milliseconds
second, seconds
minute, minutes
hour, hours
day, days
week
month, months
quarter, quarters
year, years
Unsupported formats in Snowflake for DATEADD
:
weeks
decade, decades
century, centuries
millennium, millennia
Grammar Syntax
Sample Source Patterns
Supported date parts:
Input Code:
Output Code:
Unsupported date parts
This transformation is performed in order to emulate Redshift behavior for the following date parts
weeks is converted to its equivalent supported date part,
week
.
The following date parts are transformed to their equivalent in years
:
decade, decades : converted to year times ten.
century, centuries: converted to year times one hundred.
millennium, millennia: converted to year times one thousand.
Input Code:
Output Code:
Notes
In Amazon Redshift, when you use DATEADD
to add years to February 29 of a leap year, it rolls over to March 1 of the following year because the next year is not a leap year. Redshift handles date arithmetic by moving to the nearest valid date. Since February 29 does not exist in non-leap years, it defaults to March 1. For example, adding one year to February 29, 2020, results in March 1, 2021.
Related EWIs
There are no known issues.
Last updated