av激情亚洲男人的天堂国语,日韩欧美精品一中文字幕,无码av一区二区三区无码,国产又色又爽又刺激的a片,国产又色又爽又刺激的a片

大于等于28SQLServer中超過(guò)28天的月份統(tǒng)計(jì)(sqlserver月幾天)

there are occasions when one may want to calculate months with more than 28 days in SQL Server. The challenge that may arise is that a generic T-SQL function does not exist for this computation. Nonetheless, the ability to perform such computation is made possible through the proper use of date functions in T-SQL, combined with the ability to leverage cursors or a looping construct within a stored procedure.

成都創(chuàng)新互聯(lián)是一家專注于成都網(wǎng)站制作、成都做網(wǎng)站、外貿(mào)營(yíng)銷(xiāo)網(wǎng)站建設(shè)與策劃設(shè)計(jì),江口網(wǎng)站建設(shè)哪家好?成都創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設(shè)10余年,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:江口等地區(qū)。江口做網(wǎng)站價(jià)格咨詢:13518219792

In this post, we shall be focusing on how to count the number of months in SQL Server with a duration of more than 28 days. We shall start by creating a cursor to loop through each year and month, and then use a combination of several date functions to achieve the desired outcome.

首先,我們創(chuàng)建一個(gè)游標(biāo)來(lái)循環(huán)每一年和每一個(gè)月:

— Declare Cursor declare c1 cursor for select distinct year(date) as [year], month(date) as [month] from tablename order by [year], [month]

接下來(lái),我們使用dateadd函數(shù)來(lái)計(jì)算每個(gè)月的總天數(shù):

declare @days int, @month date set @month = dateadd(mm, 1, datefromparts(@year, @month, 1)) set @days = datediff(dd, datefromparts(@year, @month, 1), @month)

隨后,我們通過(guò)比較總天數(shù)是否大于28來(lái)判斷每個(gè)月是否包含天數(shù)大于28天:

if @days > 28 begin — Increment the count set @longmonthcount = @longmonthcount + 1 end

最后,我們返回結(jié)果:

— Return result select @longmonthcount count

因此,以上代碼是如何用游標(biāo)和dateadd函數(shù)統(tǒng)計(jì)超過(guò)28天的月份。這種方法可以確保實(shí)現(xiàn)這種統(tǒng)計(jì)。

成都網(wǎng)站建設(shè)選創(chuàng)新互聯(lián)(?:028-86922220),專業(yè)從事成都網(wǎng)站制作設(shè)計(jì),高端小程序APP定制開(kāi)發(fā),成都網(wǎng)絡(luò)營(yíng)銷(xiāo)推廣等一站式服務(wù)。


分享標(biāo)題:大于等于28SQLServer中超過(guò)28天的月份統(tǒng)計(jì)(sqlserver月幾天)
URL網(wǎng)址:http://uogjgqi.cn/article/dpjiiso.html
掃二維碼與項(xiàng)目經(jīng)理溝通

我們?cè)谖⑿派?4小時(shí)期待你的聲音

解答本文疑問(wèn)/技術(shù)咨詢/運(yùn)營(yíng)咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流