microseconds_sub
从日期值中减去一个时间间隔。时间间隔以微秒为单位。
语法
DATETIME microseconds_sub(DATETIME expr1,INT expr2);
参数
expr1
:时间表达式。必须是 DATETIME 类型。
expr2
:要减去的时间间隔,以微秒为单位。必须是 INT 类型。
返回值
返回 DATETIME 类型的值。如果输入值为 DATE 类型,则小时、分钟和秒部分将处理为 00:00:00
。
示例
select microseconds_sub('2010-11-30 23:50:50', 2);
+--------------------------------------------+
| microseconds_sub('2010-11-30 23:50:50', 2) |
+--------------------------------------------+
| 2010-11-30 23:50:49.999998 |
+--------------------------------------------+
select microseconds_sub('2010-11-30', 2);
+-----------------------------------+
| microseconds_sub('2010-11-30', 2) |
+-----------------------------------+
| 2010-11-29 23:59:59.999998 |
+-----------------------------------+