显示基于周()结果的日期,星期日除外 [英] Display dates based on week() result, except Sunday
本文介绍了显示基于周()结果的日期,星期日除外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我们都知道,我们可以通过使用 week()函数。我的问题是如何显示那个星期日以外的那个星期的日期?
So we all know that we can get the week number of a date by using the week() function. My question is how to display the dates of that particular week, except the Sunday date?
要说明..
< img src =https://i.stack.imgur.com/WCaWZ.pngalt =在此输入图像说明>
基于上面的例子,我想要显示的是..
Based from the above example, what I want to display is..
- 2009-05-17
- 2009-05-18
- 2009-05-19
- 2009-05-20
- 2009- 05-21
- 2009-05-22
- 2009-05-17
- 2009-05-18
- 2009-05-19
- 2009-05-20
- 2009-05-21
- 2009-05-22
如何查询? p>
How do I query this?
推荐答案
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)=@YearNum
AND WEEK(selected_date)=@WeekNum
AND WEEKDAY(selected_date)<> 6;
这篇关于显示基于周()结果的日期,星期日除外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文