在mysql中选择的每周明智日期

时间:2015-01-09 06:22:39

标签: php mysql sql

我尝试过的查询

如何在mysql查询中获取当前周日期?

SELECT WShipDate FROM `pipo_orders` where WEEKOFYEAR(`WShipDate`) >= WEEKOFYEAR(NOW())

WShipDate
2015-01-10
2015-01-19
2015-01-08
2014-12-25
2014-01-05
2015-01-01

我的预期输出是

2014-01-05
2015-01-08
2015-01-10

希望使用mysql查询获取每周日期。是否可能?

1 个答案:

答案 0 :(得分:0)

试试这个

从下面的查询中你可以得到你的输出试试这个

<?php 
 $weekstartday = date("Y-m-d",strtotime('monday this week'));
 $weekendday = date("Y-m-d",strtotime('sunday this week')); 

$sql = "SELECT * FROM `pipo_orders` WHERE `WShipDate` between '$weekstartday' and '$weekendday'";

?>