1. 程式人生 > >mysql 查詢當天、最近一天、最近一週,本月,上一個月的資料

mysql 查詢當天、最近一天、最近一週,本月,上一個月的資料

#查詢本季度資料
select * from `ht_invoice_information` where QUARTER(create_date)=QUARTER(now());
#查詢上季度資料
select * from `ht_invoice_information` where QUARTER(create_date)=QUARTER(DATE_SUB(now(),interval 1 QUARTER));
#查詢本年資料
select * from `ht_invoice_information` where YEAR(create_date)=YEAR(NOW());
#查詢上年資料
select * from `ht_invoice_information` where year(create_date)=year(date_sub(now(),interval 1 year));