Syntax
TIMESTAMPDIFF(<String>;<Date>;<Date>)
Description
Returns the number of whole date intervals between two date arguments. The size of the date interval is indicated by a string argument (supported interval arguments are 'YEAR', 'QUARTER', 'MONTH', 'WEEK', 'DAY', 'HOUR', 'MINUTE', 'SECOND', or 'MILLISECOND'). The interval is calculated by subtracting the first date argument (Date1) from the second (Date2). If Date2 is before Date1, the value returned by the function will be negative.
Examples
String | Date1 | Date2 | TIMESTAMPDIFF Returns |
---|---|---|---|
YEAR | Jun 14, 2011 12:23:05 PM | Jun 14, 2018 12:23:05 PM | 7 |
YEAR | Jun 14, 2018 12:23:05 PM | Jun 14, 2011 12:23:05 PM | -7 |
QUARTER | Jun 14, 2011 12:23:05 PM | Jun 14, 2018 12:23:05 PM | 28 |
MONTH | Jun 14, 2011 12:23:05 PM | Jun 14, 2018 12:23:05 PM | 84 |
WEEK | Jun 14, 2011 12:23:05 PM | Jun 14, 2018 12:23:05 PM | 365 |
DAY | Jun 14, 2011 12:23:05 PM | Jun 14, 2018 12:23:05 PM | 2,557 |
HOUR | Jun 14, 2011 12:23:05 PM | Jun 14, 2018 12:23:05 PM | 61,368 |
MINUTE | Jun 14, 2011 12:23:05 PM | Jun 14, 2018 12:23:05 PM | 3,682,080 |
SECOND | Jun 14, 2011 12:23:05 PM | Jun 14, 2018 12:23:05 PM | 220,924,800 |
MILLISECOND | Jun 14, 2011 12:23:05 PM | Jun 14, 2018 12:23:05 PM | 220,924,800,000 |