当前位置:Gxlcms > 数据库问题 > sql:mysql:函数:TIMESTAMPDIFF函数实现TimeStamp字段相减,求得时间差

sql:mysql:函数:TIMESTAMPDIFF函数实现TimeStamp字段相减,求得时间差

时间:2021-07-01 10:21:17 帮助过:10人阅读

avg(TIMESTAMPDIFF(MINUTE,CREATE_DTTM,UPLOAD_TIME)) value,LEFT(CREATE_DTTM,10) time from 表名
  • WHERE
  • CREATE_DTTM >= ‘2018-01-21‘
  • AND CREATE_DTTM <=DATE_ADD( ‘2019-02-19‘,INTERVAL 1 DAY) and UPLOAD_TIME is not null
  • group by LEFT(CREATE_DTTM,10)
  • 参考:https://blog.csdn.net/yiifaa/article/details/78611079

    https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_microsecond

    技术图片

     

    1. mysql> SELECT TIMESTAMPDIFF(MONTH,‘2003-02-01‘,‘2003-05-01‘);
    2. -> 3
    3. mysql> SELECT TIMESTAMPDIFF(YEAR,‘2002-05-01‘,‘2001-01-01‘);
    4. -> -1
    5. mysql> SELECT TIMESTAMPDIFF(MINUTE,‘2003-02-01‘,‘2003-05-01 12:05:55‘);
    6. -> 128885

    人气教程排行