mysql查詢當天 周 月,上個月的資料

2021-06-22 06:23:38 字數 1296 閱讀 2598

查詢當天的記錄

select * from table where to_days(hb_addtime) = to_days(now())

查詢當前這週的資料

select name,submittime from table where yearweek(date_format(submittime,』%y-%m-%d』)) = yearweek(now());

查詢上週的資料

select name,submittime from table where yearweek(date_format(submittime,』%y-%m-%d』)) = yearweek(now())-1;

查詢當前月份的資料

select name,submittime from table where date_format(submittime,』%y-%m』)=date_format(now(),』%y-%m』)

查詢距離當前現在6個月的資料

select name,submittime from table where submittime between date_sub(now(),interval 6 month) and now();

查詢上個月的資料

select name,submittime from table 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 date format now y m d interval day date format now y m d dayas 上個月最後一天 date format date add now interval 1 month y m d interval day date format...

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