---
title: "MySql 查询特定时间段数据"
author: "wangheid"
date: "2012-11-21T14:48:48Z"
tags: []
categories: ["数据库"]
slug: "mysql"
draft: false
lastmod: "2012-11-21T15:46:49Z"
id: 1732141
url: "https://wangjiabei.iteye.com/blog/1732141"
---

```
select * from wap_content where week(created_at) = week(now)

如果你要严格要求是某一年的，那可以这样

查询一天：

select * from table where to_days(column_time) = to_days(now());
select * from table where date(column_time) = curdate(); 

查询一周：

select * from table  where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(column_time);

查询一个月：

select * from table  where DATE_SUB(CURDATE(), INTERVAL 1 MONTH) <= date(column_time);
```