An expression whose value is a DATE, DATETIME, or DATETIME-TZ.
datetime2
An expression whose value is a DATE, DATETIME, or DATETIME-TZ.
interval-unit
A character constant, or a character expression that evaluates
to one of the following time units: ‘years', ‘months',
‘weeks', ‘days', 'hours', ‘minutes',
‘seconds' or ‘milliseconds'. These
values are case insensitive and might be singular.
Notes
This
function returns a signed integer value (positive or negative).
For example, if datetime1 is less than datetime2,
the INTERVAL function returns a negative value.
If datetime1 or datetime2 is
a DATE or DATETIME, the time value defaults to midnight and the
time zone value defaults to the session's time zone, respectively.
You are responsible for managing value overflow, if any.
When used with 'months', the INTERVAL function does not take into
account that not all months have the same number of days. For example, when determining if
an interval between dates in two consecutive months is one full month, the function only
checks to see if the day in the date of the later month is greater than or equal to the
day in the date of the earlier month. Both of the following function calls return '0',
i.e., not a full month, in spite of the fact that the second example involves the calendar
end dates of March and April.