Addition and Subtraction Functions
The table below contains the supported unit
for the following functions.
Unit | Description |
---|---|
| Seconds |
| Minutes |
| Hours |
| Days |
| Weeks |
| Months |
| Quarters |
| Years |
DATE_ADD( [ <unit>, ] value, <date_expr> ) or DATEADD( [ <unit>, ] value, <date_expr> )
Returns a date expression after adding an interval value
of type unit
to the input date expression.
DATE_DIFF( <date expr1>, <date_expr2> [, <unit> ] )
Returns the number of units between two date expressions.
unit
- optional - The unit used to calculate the difference. Default value: day.
DATE_DIFF( [ <unit>, ] <date expr1>, <date_expr2> )
Returns the number of units between two date expressions.
unit
- optional - The unit used to calculate the difference. Default value: day.
DATEDIFF( [ <unit> ] , <date expr1>, <date_expr2> )
Returns the number of units between two date expressions.
unit
- optional - The unit used to calculate the difference. Default value: day.
TIMESTAMP_ADD( unit, value, <timestamp_expr> )
Returns a timestamp expression after adding an interval value
of type unit
to the input timestamp expr
.
TIMESTAMP_DIFF( <timestamp_expr1>, <timestamp_expr2>, unit )
Returns the difference of timestamp expr1
and timestamp expr2
with respect to unit
.
Date Time Operators
The following operators can be used to perform mathematical operations on date-time expressions.
+ - Addition Operator
- - Subtraction Operator
Combined Operators
Limits -
Week and quarter are not supported in interval (addition/subtraction )
Last updated