某个场景下需要查询某一天的数据,例如2017/9/27这一天所有的数据量,有以下几个方法。
SELECT * FROM cms_book_statistics WHERE substring(Convert(char(10),update_time ,112),1,8)='20170927'
SELECT * FROM cms_book_statistics WHERE update_time between '2017-09-27 00:00:00' and '2017-09-27 23:59:59'
SELECT * FROM cms_book_statistics WHERE year(update_time) = 2017 and month(update_time )= 09 and day(update_time) = 27
SELECT * FROM cms_book_statistics WHERE update_time > '2017-09-27' and update_time < '2017-09-28'
SELECT * FROM cms_book_statistics WHERE ( datediff ( update_time , '2017-09-27' ) = 0 )
---------------------
作者:Gordon家的哈士奇
来源:CSDN
原文:https://blog.csdn.net/qq_36743013/article/details/78115873
版权声明:本文为博主原创文章,转载请附上博文链接!