Home > Database > Mysql Tutorial > Mysql按时间查询的几个函数使用方法_MySQL

Mysql按时间查询的几个函数使用方法_MySQL

WBOY
Release: 2016-06-01 13:45:00
Original
1015 people have browsed it

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
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template