假设我们输入FROM日期为2014-06-01
而TO日期为2014-06-30
,那么它应该将日期设为2014-06-07,2014-06-14,2014-06-21 & 2014-06-28.
任何人都可以帮助我吗?
谢谢!!!
答案 0 :(得分:0)
您可以遍历日期并使用函数DAYNAME(date)
。它将返回传入日期的日期名称作为参数,您可以检查它是否返回“星期六”
答案 1 :(得分:0)
SELECT *
FROM TABLE_NAME
WHERE DAYNAME(`date_field`)='Saturday'
AND `date_field` BETWEEN '2014-06-01' AND '2014-06-30'
在mySql中查看Manual DAYNAME函数
答案 2 :(得分:0)
SELECT *
FROM TABLE_NAME
WHERE DAYOFWEEK(`date_field`)='7'
AND `date_field` BETWEEN '2014-06-01' AND '2014-06-30'
文档:
DAYOFWEEK(date)
Returns the weekday index for date (1 = Sunday, 2 = Monday, …, 7 = Saturday). These index values correspond to the ODBC standard