久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用 T-SQL 獲取下個(gè)月的第一個(gè)星期日

Get first Sunday of next month using T-SQL(使用 T-SQL 獲取下個(gè)月的第一個(gè)星期日)
本文介紹了使用 T-SQL 獲取下個(gè)月的第一個(gè)星期日的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

正在尋找一種以11/1/2009"格式獲取日期的方法,這將是下個(gè)月的第一個(gè)星期日.我想在 10 月的第一個(gè)星期日之后運(yùn)行此查詢以獲得下個(gè)月的第一個(gè)星期日.使用 T-SQL 查詢完成此操作的最佳方法是什么?

Looking for a way to get the date in the format "11/1/2009", which would be the first sunday of next month. I want to run this query after the first sunday in october to get the first sunday of the upcoming month. What is the best method to accomplish this with a T-SQL query?

謝謝

推薦答案

試試這個(gè):

Declare @D Datetime 
Set @D = [Some date for which you want the following months' first sunday]
Select DateAdd(day, (8-DatePart(weekday, 
    DateAdd(Month, 1+DateDiff(Month, 0, @D), 0)))%7, 
    DateAdd(Month, 1+DateDiff(Month, 0, @D), 0))

編輯注釋:

下個(gè)月的第一天由表達(dá)式給出:

The first of next Month is given by the expression:

DateAdd(Month, 1+DateDiff(Month, 0, @D), 0)

或通過(guò):通過(guò)將 1 更改為 2,可以將其修改為從現(xiàn)在起兩個(gè)月后的第一天:

or by: which can be modified to give the first of the month two months from now by changing the 1 to a 2:

DateAdd(Month, 2+DateDiff(Month, 0, @D), 0) 

響應(yīng)@NissanFan 和@Anthony:修改它以返回第一個(gè)星期一星期二星期三等,將值 8 更改為 9、10、11 等....

In response to @NissanFan, and @Anthony: to modify this to return the first Monday Tuesday Wednesday, etc, change the value 8 to a 9, 10, 11, etc....

Declare @Sun TinyInt Set @Sun = 8
Declare @Mon TinyInt Set @Mon = 9
Declare @Tue TinyInt Set @Tue = 10
Declare @Wed TinyInt Set @Wed = 11
Declare @Thu TinyInt Set @Thu = 12
Declare @Fri TinyInt Set @Fri = 13
Declare @Sat TinyInt Set @Sat = 14
Declare @D Datetime, @FONM DateTime -- FirstofNextMonth 
Set @D = [Some date for which you want the following months' first sunday]
Set @FONM = DateAdd(Month, 1+DateDiff(Month, 0, @D),0)

Select 
  DateAdd(day, (@Sun -DatePart(weekday, @FONM))%7, @FONM) firstSunInNextMonth,
  DateAdd(day, (@Mon -DatePart(weekday, @FONM))%7, @FONM) firstMonInNextMonth,
  DateAdd(day, (@Tue -DatePart(weekday, @FONM))%7, @FONM) firstTueInNextMonth,
  DateAdd(day, (@Wed -DatePart(weekday, @FONM))%7, @FONM) firstWedInNextMonth,
  DateAdd(day, (@Thu -DatePart(weekday, @FONM))%7, @FONM) firstThuInNextMonth,
  DateAdd(day, (@Fri -DatePart(weekday, @FONM))%7, @FONM) firstFriInNextMonth,
  DateAdd(day, (@Sat -DatePart(weekday, @FONM))%7, @FONM) firstSatInNextMonth

這篇關(guān)于使用 T-SQL 獲取下個(gè)月的第一個(gè)星期日的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Sql server table usage statistics(Sql server 表使用情況統(tǒng)計(jì))
Relative path in t sql?(t sql中的相對(duì)路徑?)
Getting the last record in SQL in WHERE condition(在 WHERE 條件下獲取 SQL 中的最后一條記錄)
Query to get XML output for hierarchical data using FOR XML PATH in SQL Server(在 SQL Server 中使用 FOR XML PATH 查詢以獲取分層數(shù)據(jù)的 XML 輸出)
T-SQL IF statement embedded in a sum() function(嵌入在 sum() 函數(shù)中的 T-SQL IF 語(yǔ)句)
Table vs Temp Table Performance(表與臨時(shí)表性能)
主站蜘蛛池模板: 中文天堂在线一区 | 女同久久另类99精品国产 | 欧美色图综合网 | 高清欧美性猛交xxxx黑人猛交 | 色婷婷综合久久久中字幕精品久久 | 中文字幕乱码一区二区三区 | 亚洲图片一区二区三区 | 成人在线视频观看 | 成人午夜电影网 | 亚洲欧洲在线视频 | 99re6在线视频精品免费 | 久久久成 | 极情综合网 | 国产精品一区二区视频 | 成人在线视频一区 | 97影院2| 久久久久九九九九 | 中文字幕在线一区 | 欧美操操操 | 国产电影一区二区三区爱妃记 | 成人精品福利 | 欧美区在线观看 | 久久专区 | 秋霞a级毛片在线看 | 精品欧美一区二区三区免费观看 | 久久伊人久久 | 欧美成人精品在线观看 | 日本午夜在线视频 | 精品一区二区三区入口 | 免费观看一级特黄欧美大片 | 婷婷五月色综合 | 日韩在线视频免费观看 | 午夜专区 | 精精国产视频 | 国产一二区免费视频 | 久久综合av | 最新日韩在线 | 特级做a爰片毛片免费看108 | 亚州午夜精品 | 不卡一区二区在线观看 | 国产91在线播放 |