本文介紹了兩個(gè)日期之間的工作日數(shù)的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
我想要日期之間的工作日數(shù).例如,如果我們有 01-01-2012 和 20-01-2012,我想使用 T-SQL 獲取這兩個(gè)日期之間的工作日數(shù).
I want number of working days in between to dates. For example if we have 01-01-2012 and 20-01-2012, i want to get the number of working days in between that two dates using T-SQL.
推薦答案
由于 SQL Server 不知道貴公司認(rèn)為工作日是多少,因此這個(gè)問題的最佳答案可能是使用 日歷表.一旦你有一個(gè)包含過去和未來日期的表,并且像 IsWorkDay
這樣的列正確更新,查詢就很簡單:
Since SQL Server has no idea what your company considers working days, the best answer to this problem is likely going to be to use a calendar table. Once you have a table with past and future dates, with a column like IsWorkDay
correctly updated, the query is simple:
SELECT [Date] FROM dbo.Calendar
WHERE [Date] >= @start
AND [Date] <= @end
AND IsWorkDay = 1;
這篇關(guān)于兩個(gè)日期之間的工作日數(shù)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!