One, the use of Timestampdiff (interval,datetime_expr1,datetime_expr2)
Returns an integer difference between a date or datetime expression Datetime_expr1 and datetime_expr2the. The unit of the result is given by the interval parameter.
Instance:
Select Timestampdiff (Day,'2017-01-01','2017-01-09 ')
Output results:8
Select Timestampdiff (MINUTE,'2017-01-01','2017-01-09'
Output: One,520
Second, the use of Timestampadd (interval,int_expr,datetime_expr)
Adds an integral expression int_expr to a date or datetime expression datetime_expr.
Instance:
Select Timestampadd (Day,5,'2017-01-01 08:00:00' )
Output: £ºxx:
Select Timestampadd (QUARTER,2,'2017-01-01 08:00:00');
output:-£ º XX:
The interval parameter values are as follows:
- Frac_second. Indicates that the interval is milliseconds
- SECOND. Seconds
- MINUTE. Minutes
- HOUR. Hours
- Day. Days
- WEEK. Week
- MONTH. Month
- QUARTER. Quarter
- Year. Years
The use of Timestampdiff and Timestampadd functions in MySQL