- 當天的資料
select * from table where to_days(column_time) = to_days(now()); select * from table where date(column_time) = curdate();
- Between日期
注意結尾是最後一天一秒,否則只會出現到前一天的資料WHERE (created BETWEEN '2012-06-19' and '2012-06-30 23:59:59' );
- 最近7天,1個月
WHERE DATE_SUB( CURDATE( ) , INTERVAL 7 DAY ) <= `created_date`; WHERE DATE_SUB(CURDATE(), INTERVAL INTERVAL 1 MONTH) <= `created_date`;
- 本周
從當週的Sunday開始到星期六的七天資料
select * from wap_content where week(created_at) = week(now);
沒有留言:
張貼留言