Sql Server 查詢一段日期內的所有禮拜天,sql禮拜天

來源:互聯網
上載者:User

Sql Server 查詢一段日期內的所有禮拜天,sql禮拜天

 /*查詢一段日期內的所有禮拜天@startdate 開始日期@enddate 結束日期 */ declare @startDate datetimedeclare @endDate datetimedeclare @week varchar(20)set @startDate = '20150101'set @endDate = '20151231'while @startDate <= @endDate beginset @week = DATENAME(weekday, @startDate);if (@week = '星期六' or @week = '星期日')beginselect DATENAME(YEAR, @startDate) as "year", @startDate as "day"endset @startDate = @startDate + 1;end

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.