Several commonly used time functions in mysql check the api documentation each time they write SQL statements about the time. In large space, they can be found in just half a day, to improve efficiency, take the lead in recording several commonly used time SQL functions as follows: www.2cto.com 1. function used to evaluate the time difference: Java code TIMESTAMPDIFF (interval, int_expr, datetime_expr) returns the integer difference between the datetime or datetime expression datetime_expr1 and datetime_expr2. The unit of the result is given by the interval parameter.
The value of interval must be one of the Java code FRAC_SECOND, SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, or YEAR. For example: Java code mysql> select timestampdiff (MONTH, '2017-02-01 ', '2017-05-01'); www.2cto.com-> 3
2. Add time: Java code TIMESTAMPADD (interval, int_expr, datetime_expr) Add the integer expression int_expr to the date or date time expression datetime_expr. The unit of int_expr is given by the interval parameter. The parameter value is the same as the preceding one. For example: Java code mysql> select timestampadd (MINUTE, 1, '2017-01-02 ');-> '2017-01-02 00:01:00' mysql> select timestampadd (WEEK, 1, '2017-01-02 ');-> '2017-01-09' By gwh_08