Mysql按时间查询的几个函数使用方法_MySQL
程序员文章站
2022-06-10 18:00:43
...
bitsCN.com
查询昨天的数据 select * from faq where answer_time = date_sub(curdate(),interval 1 day);
查询本月的数据 select name,submittime from enterprise where date_format(submittime,'%Y-%m')=date_format(now(),'%Y-%m');
查询今天的数据 select * from faq where date_format(answer_time,'%y-%m-%d') = date_format(now(),'%y-%m-%d');
查询当前这周的数据 SELECT name,submittime FROM enterprise WHERE YEARWEEK(date_format(submittime,'%Y-%m-%d')) = YEARWEEK(now());
作者“csupanpan的专栏”
bitsCN.com推荐阅读
-
MySQL的时间差函数TIMESTAMPDIFF、DATEDIFF的用法
-
MySQL的时间差函数(TIMESTAMPDIFF、DATEDIFF)、日期转换计算函数(date_add、day、date_format、str_to_date)
-
Mysql根据时间查询日期的优化技巧
-
mysql 时间转换函数的使用方法第1/2页
-
php和mysql关于时间的实用函数
-
ms sql server中实现的unix时间戳函数(含生成和格式化,可以和mysql兼容)
-
详解 Mysql查询结果顺序按 in() 中ID 的顺序排列
-
mysql的日期和时间函数大全第1/2页
-
MySQL使用集合函数查询的实例
-
MySQL DATEDIFF函数获取两个日期的时间间隔的方法