SET @GivenDate ='2016-05-27';
SET @YearNum = YEAR(@GivenDate);
SET @WeekNum=WEEK(@GivenDate);
select selected_date,weekday(selected_date) AS WeeKDate
from
(select adddate('1970-01-01',t4.i*10000 + t3.i*1000 + t2.i*100 + t1.i*10 + t0.i) selected_date from
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t0,
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t1,
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t2,
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t3,
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t4) v
where YEAR(selected_date)[email protected]
AND WEEK(selected_date)[email protected]
AND WEEKDAY(selected_date)<> 6;
これは機能します、ありがとうございます。しかし、「2016-05-27」に設定しようとすると、日曜日の「2016-05-22」から「2016-05-27」に始まります。それは '2016-05-23' - ' 2016-05-28'でなければなりません。 – xjshiya
更新されたコードをご覧ください。 – Sandesh
これは機能します!本当にありがとう! :) – xjshiya