date_sub(date, interval num unit) date代表日期时间,interval 为固定参数,num为偏移量, unit为偏移的单位 SELECT DATE_SUB("2021-01-01 12:34:56",INTERVAL 7 YEAR) AS yaer, DATE_SUB("2021-01-01 12:34:56",INTERVAL 7 MONTH) AS month, DATE_SUB("2021-01-01 12:34:56",INTERVAL 7 DAY) ...
Date Time Functions DATE_SUBmysql> mysql> select DATE_SUB(curdate(), INTERVAL 1 DAY); +---+ | DATE_SUB(curdate(), INTERVAL 1 DAY) | +---+ | 2007-07-21 | +---+ 1 row in set (0.00 sec) mysql> 14.12.DATE_SUB 14.12.1. DATE_SUB(date,INTERVAL expr unit) 14.12.2. DATE_SUB...
AND p.review_status = 1 AND p.create_time >= subdate(current_date, INTERVAL 10 day) AND pt.topic_id =#{cityId} <iftest="num == 2"> ORDER BY p.hot_score DESC, p.id DESC </if> <iftest="num == 3"> ORDER BY p.create_time DESC, p.id DESC </if>...
mysql> SELECT "1997-12-31 23:59:59" + INTERVAL 1 SECOND; -> 1998-01-01 00:00:00 mysql> SELECT INTERVAL 1 DAY + "1997-12-31"; -> 1998-01-01 mysql> SELECT "1998-01-01" - INTERVAL 1 SECOND; -> 1997-12-31 23:59:59 mysql> SELECT DATE_ADD("1997-12-31 23:59:59", INTE...
| s | DATE_ADD(date, numDays) | Returns the DATE that is *numDays* after *date* | b | DATE_DIFF(date, date2, timeUnit) | Returns the whole number of *timeUnit* between *date* and *date2* | b | DATE_SUB(date, interval) | Returns the DATE value that occurs *interval* befo...
DATE_SUB(date,INTERVALexpr unit) 1. date: The input date or datetime value from which the time interval will be subtracted. INTERVAL expr unit: Specifies the time interval to subtract.expris the number of units to subtract, andunitis the time unit (e.g., DAY, MONTH, YEAR). ...
date_sub(startDate, numDays) АргументыstartDate:выражение DATE. numDays:выражение INTEGER.ВозвращаетДАТА.Если numDaysимеетотрицательноезначение abs(num_days), добавляютсяв startDate.Е...
有关INTERVAL和unit参数的信息,请参见DATE_ADD。 SUBDATE(expr,days)允许使用days的整数值。在这种情况下,它被解释为从日期或日期时间表达式expr中减去的天数。 示例 obclient>SELECTDATE_SUB('2022-01-02',INTERVAL31DAY);+---+|DATE_SUB('2022-01-02',INTERVAL31DAY)|+---+|2021-12-02|+---+1rowi...
DATE_SUB(date, INTERVAL expr unit) 其中date 为日期值,expr 为表达式,unit 为一个有效的日期时间 单位,如 year,month,day,hour 等。 date sub 函数可以使用在多种场景中,比如可以用来计算某一天后 的某一天,或者用来计算某一天前的某一天。例如,可以用 date sub 函数计算出明天的日期: SELECT DATE_SUB(CUR...
DATE_SUB, MICROSECOND 间隔单位:毫秒 SECOND 间隔单位:秒 MINUTE 间隔单位:分钟 HOUR 间隔单位:小时 DAY 间隔单位:天 WEEK 间隔单位:星期 MONTH 间隔单位:月 QUARTER 间隔单位:季度 YEAR 间隔单位:年 DATE_SUB 将从一个日期/时间值中减去一个时间值(时间间隔)。 其函数中用法表达式为:DATE_SUB(date,INTERVAL...