简体   繁体   English

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

[英]How to get particular date in 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. 它显示了2014-10-18和2014-10-22之间的所有记录。 Now I want only 2014-10-18, 2014-10-20 and 2014-10-22 date's records. 现在我只想要2014-10-18、2014-10-20和2014-10-22日期的记录。 If I run this query tomorrow, it should show 2014-10-19, 2014-10-21 and 2014-10-23 如果我明天运行此查询,则应显示2014-10-19、2014-10-21和2014-10-23

and My PHP code: 和我的PHP代码:

$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 谢谢

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM