欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

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
相关标签: 查询