如何在mysql中获取特定日期?

如何在mysql中获取特定日期?

问题描述:

This is my query.

SELECT *
FROM `mystores`
WHERE `status`='0'
  AND DATE(`create_date`) < '2014-10-23'
  AND DATE(`create_date`) > '2014-10-17'

and it shows all the records between 2014-10-18 and 2014-10-22. Now I want only 2014-10-18, 2014-10-20 and 2014-10-22 date's records. If I run this query tomorrow, it should show 2014-10-19, 2014-10-21 and 2014-10-23

and My PHP code:

$sql="SELECT * FROM `mystores` WHERE `status`='0' AND  DATE(`create_date`) < '".date("Y-m-d", strtotime("-1 day"))."' AND DATE(`create_date`) > '".date("Y-m-d", strtotime("-7 days"))."'";

Is there any possible to get these records? Thanks

这是我的查询。 p>

  SELECT * 
FROM`  mystores` 
WHERE`status` ='0'
 AND DATE(`create_date`)&lt;  '2014-10-23'
 AND DATE(`create_date`)&gt;  '2014-10-17'
  code>  pre> 
 
 

它显示2014-10-18和2014-10-22之间的所有记录。 我现在只想要2014- 10-18,2014-10-20和2014 - 10 - 22日期的记录。 如果我明天运行此查询,则应显示2014-10-19,2014-10-21和2014-10-23 p>

和我的PHP代码: p>

  $ sql =“SELECT * FROM`mystores` WHERE`status` ='0'AND DATE(`create_date`  )&lt;'“。日期(”Ymd“,strtotime(” -  1天“))。”'和日期(`create_date`)&gt;'“。日期(”Ymd“,strtotime(” -  7天“))  )。“'”; 
  code>  pre> 
 
 

有没有可能获得这些记录? 谢谢 p> div>

SELECT *
FROM `mystores`
WHERE `status`='0'
  AND DATE(`create_date`) in (curdate() - interval 2 day,
                              curdate() - interval 4 day,
                              curdate() - interval 6 day)