mysql查詢本週、上週、本月、上個月份資料的sql**-
mysql查詢的方式很多,下面為您介紹的mysql查詢實現的是查詢本週、上週、本月、上個月份的資料,如果您對mysql查詢方面感興趣的話,不妨一看
-查詢當前這週的資料
select name,submittime from enterprise where yearweek(date_format(submittime,'%y-%m-%d')) = yearweek(now());
查詢上週的資料
select name,submittime from enterprise where yearweek(date_format(submittime,'%y-%m-%d')) = yearweek(now())-1;
查詢當前月份的資料
select name,submittime from enterprise where date_format(submittime,'%y-%m')=date_format(now(),'%y-%m')
查詢距離當前現在6個月的資料
select name,submittime from enterprise where submittime between date_sub(now(),interval 6 month) and now();
查詢上個月的資料
select name,submittime from enterprise where date_format(submittime,'%y-%m')=date_format(date_sub(curdate(), interval 1 month),'%y-%m')
select * from `user` where date_format(pudate,'%y%m') = date_format(curdate(),'%y%m') ;
select * from user where weekofyear(from_unixtime(pudate,'%y-%m-%d')) = weekofyear(now())
select *
from user
where month(from_unixtime(pudate,'%y-%m-%d')) = month(now())
select *
from [user]
where year(from_unixtime(pudate,'%y-%m-%d')) = year(now())
and month(from_unixtime(pudate,'%y-%m-%d')) = month(now())
select *
from [user]
where pudate between
詳細出處參考:
MySQL查詢本週 上週 本月 上個月份的資料
mysql查詢的方式很多,下面為您介紹的mysql查詢實現的是查詢本週 上週 本月 上個月份的資料,如果您對mysql查詢方面感興趣的話,不妨一看。查詢當前這週的資料 selectname,submittimefromenterprisewhereyearweek date format submi...
MySQL查詢本週 上週 本月 上個月份的資料
今天 select from 表名 where to days 時間字段 to days now 昨天 select from 表名 where to days now to days 時間字段 1 近7天 select from 表名 where date sub curdate interval...
sql時間查詢上週 本週 上月 本月
如何實現只顯示本月資訊 sql select from table where datediff m,date,now 0 sql 查詢本週本月 求相差天數 select datediff day,2004 01 01 getdate 1.乙個月第一天的 select dateadd mm,date...