The function TIMESTAMPDIFF returns a new timestamp value based on adding an
interval to an existing timestamp value.
SQL Syntax:
|
|
TIMESTAMPADD (interval, timestamp1, timestamp2) |
Interval:
|
|
One of the follow constants SQL_TSI_FRAC_SECOND,
SQL_TSI_SECOND, SQL_TSI_MINUTE,
SQL_TSI_HOUR, SQL_TSI_DAY, SQL_TSI_WEEK,
SQL_TSI_MONTH, SQL_TSI_QUARTER, or
SQL_TSI_YEAR
|
timestamp1, timestamp2:
|
|
A timestamp expression. |
Escape Syntax:
|
|
{fn TIMESTAMPDIFF (interval, timestamp1, timestamp2)} |
Return Type:
|
|
INT |
Alternative Function Names:
|
|
DATEDIFF: This is the equivalent from the MS SQL Server. |
Alternative Interval Names: |
|
Year yy, yyyy
quarter qq, q
Month mm, m
dayofyear dy, y
Day dd, d
Week wk, ww
Hour hh
minute mi, n
second ss, s
millisecond ms |
Examples:
SELECT timestampadd( SQL_TSI_DAY, mydate, now())
from mytable
see also:
SQL Date Time Functions
|