Mysql 查詢當前這週的資料

2021-07-03 11:27:15 字數 1318 閱讀 3267

查詢當前這週的資料 

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 上月最後一天 and 下月第一天;

Mysql 查詢當前這週的資料

查詢當前這週的資料 select name,submittime from enterprise where yearweek date format submittime,y m d yearweek now 查詢上週的資料 select name,submittime from enterpri...

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 interva...

MYsql 查詢 查詢當前月份的資料(時間 查詢)

mysql查詢的方式很多,下面為您介紹的mysql 查詢實現的是查詢本週 上週 本月 上個月份的資料,如果您對mysql查詢方面感興趣的話,不妨一看。查詢當前這週的資料 select name,submittime from enterprise where yearweek date format...