mysql獲取7天前數(shù)據(jù),日期比較
select * from news where n_date>unix_timestamp( subdate( now() , interval 7
day ))order by n_click? desc
N天內(nèi)記錄
WHERE TO_DAYS(NOW()) - TO_DAYS(時(shí)間字段) <= N
今天的記錄
where date(時(shí)間字段)=date(now())
或
where to_days(時(shí)間字段) = to_days(now());
查詢一周:
select * from table?? where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(column_time);
查詢一個(gè)月:
select * from table where DATE_SUB(CURDATE(), INTERVAL INTERVAL 1 MONTH) <= date(column_time);