2014-04-24 41 views

回答

9

時間類型你的日期字段必須

和SQL查詢將是這樣的:

SELECT * 
FROM TABLE_NAME 
WHERE yearweek(DATE(field_name), 1) = yearweek(curdate(), 1) 
+0

第二個參數是用於設置星期一到星期一,所以如果它需要從星期日到星期日,那麼不需要通過2 nd param。 +1這個答案! –

0

像這樣的東西應該工作:

SELECT DATE(week, DATEDIFF(day, 0, getdate())/7, 0) AS StartWeek, 
DATE(week, DATEDIFF(day, 0, getdate())/7, 5) AS EndWeek 
相關問題