mysql查詢指定日期資料

2021-09-01 05:24:38 字數 549 閱讀 7474

查詢今天

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 7 day) <= date(時間欄位名)

近30天

select * from 表名 where date_sub(curdate(), interval 30 day) <= date(時間欄位名)本月

select * from 表名 where date_format( 時間欄位名, '%y%m' ) = date_format( curdate( ) , '%y%m' )

上一月

select * from 表名 where period_diff( date_format( now( ) , '%y%m' ) , date_format( 時間欄位名, '%y%m' ) ) =1

mysql 固定日期 mysql查詢指定日期

1.今天 select from hb contract in h where to days modify date to days now 2.昨天 select from hb contract in h where to days now to days modify date 1 3.近七...

mysql 查詢指定日期格式

mysql 查詢指定日期格式,使用 date format date,format 函式 select date format create date,y m d h i s as create date from tableselect date format a.submit time,y as...

mysql指定日期加

mysql時間加減函式為date add date sub 定義和用法 date add 函式向日期新增指定的時間間隔。date sub 函式向日期減少指定的時間間隔。語法date add date,interval expr type date sub date,interval expr typ...