Quantcast
Channel: 白河子工作室-ASP成绩查询系统、在线报名系统
Viewing all articles
Browse latest Browse all 24

【mysql】查询某一年 某一月 某一天的数据

$
0
0

查询某一年 某一月 某一天的数据(可组合)

select * fromymt where date_format(inDate,'%Y-%m-%d')='2016-10-10';

 (inDate为表中列名)



MySQL查询一天,查询一周,查询一个月内的数据

查询一天

select * from ymt where DATE(inDate)=CURDATE();    

select * from ymt where to_days(inDate)=to_days(now());

 

查询一周:

select * from table where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= DATE(column_time);

 

查询一个月:

select * fromtable where DATE_SUB(CURDATE(), INTERVAL 1 MONTH) <= DATE(column_time);

 

查询选择所有 date_col 值在最后 30 天内的记录。  

Select something FROM tbl_name

            Where TO_DAYS(NOW()) -TO_DAYS(date_col) <= 30;

 

DATE_ADD(date,INTERVALexpr type)

DATE_SUB(date,INTERVALexpr type)


Viewing all articles
Browse latest Browse all 24

Trending Articles