sql查询时间段内所有周六日

查询说时间段内所有周六日

DECLARE @t TABLE(date0 DATETIME) DECLARE @st DATETIME,@et DATETIME SET @st
='2007-01-01' SET @et='2008-01-01' WHILE @st <@et BEGIN INSERT INTO @t VALUES(@st) SELECT @st=DATEADD(DAY,1,@st) END SELECT date0,DATENAME(weekday,date0) FROM @t WHERE DATEPART(weekday,date0+@@DATEFIRST-1) IN (6,7)

 

posted @ 2017-06-19 20:28  hlb  阅读(3676)  评论(0编辑  收藏  举报