日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
大于等于28SQLServer中超過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)營銷網(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)來循環(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]

接下來,我們使用dateadd函數(shù)來計(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)

隨后,我們通過比較總天數(shù)是否大于28來判斷每個(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ì)超過28天的月份。這種方法可以確保實(shí)現(xiàn)這種統(tǒng)計(jì)。

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


本文題目:大于等于28SQLServer中超過28天的月份統(tǒng)計(jì)(sqlserver月幾天)
標(biāo)題來源:http://m.5511xx.com/article/dpjiiso.html