mysql日期相减取小时
TIMESTAMPDIFF(HOUR,a.StartTime,a.EndTime)
HOUR,开始时间,结束时间
select TIMESTAMPDIFF(HOUR,'2019-02-01','2019-02-02')
欢迎各位兄弟 发布技术文章
这里的技术是共享的
mysql日期相减取小时
TIMESTAMPDIFF(HOUR,a.StartTime,a.EndTime)
HOUR,开始时间,结束时间
select TIMESTAMPDIFF(HOUR,'2019-02-01','2019-02-02')
来自 https://www.cnblogs.com/penghq/p/8657064.html
在应用时,经常要使用这两个函数TIMESTAMPDIFF和TIMESTAMPADD。 一,TIMESTAMPDIFF 语法: TIMESTAMPDIFF(interval,datetime_expr1,datetime_expr2)。 说明: 返回日期或日期时间表达式datetime_expr1 和datetime_expr2the 之间的整数差。其结果的单位由interval 参数给出。该参数必须是以下值的其中一个: FRAC_SECOND。表示间隔是毫秒 SECOND。秒 MINUTE。分钟 HOUR。小时 DAY。天数 WEEK。星期 MONTH。月数 QUARTER。季度 YEAR。年数mysql> select TIMESTAMPDIFF(day,'2012-08-24','2012-08-30');
+----------------------------------------------+
| TIMESTAMPDIFF(day,'2012-08-24','2012-08-30') |
+----------------------------------------------+
| 6 |
+----------------------------------------------+
1 row in set (0.00 sec)
mysql> select TIMESTAMPDIFF(MINUTE,'2012-08-24 09:00:00','2012-08-30 12:00:00');
+-------------------------------------------------------------------+
| TIMESTAMPDIFF(MINUTE,'2012-08-24 09:00:00','2012-08-30 12:00:00') |
+-------------------------------------------------------------------+
| 8820 |
+-------------------------------------------------------------------+
1 row in set (0.01 sec)
二,TIMESTAMPADDmysql> select TIMESTAMPADD(MINUTE,8820,'2012-08-24 09:00:00');
+-------------------------------------------------+
| TIMESTAMPADD(MINUTE,8820,'2012-08-24 09:00:00') |
+-------------------------------------------------+
| 2012-08-30 12:00:00 |
+-------------------------------------------------+
1 row in set (0.00 sec)
来自 https://blog.csdn.net/zmxiangde_88/article/details/8011661