看板 Database 關於我們 聯絡資訊
;with tb1 as( select date = convert(datetime,'20180101') union all select date + 1 from tb1 where date < '20181231' ) select *,total = count(*) over (partition by 1) from tb1 where datepart(dw,date) not in (1,7) option (maxrecursion 0) ※ 引述《oherman (qq)》之銘言: : 資料庫名稱:ms sql : 資料庫版本:2016 : 內容/問題描述: : 請問TSQL如何取range工作天數及日期? : 例如: 2018/01/01 至 2018/12/31 工作天數幾天 : (去除六、日,不要管特殊國定假日如勞工節、中秋節…等) : 及 2018/01/01 至 2018/12/31 工作天日期 : (如2018/01/01,2018/01/02....,不含六、日的日期) : 有盡量不要寫function的語法嗎? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 61.223.49.25 ※ 文章網址: https://www.ptt.cc/bbs/Database/M.1545022576.A.1EA.html
oherman: 謝謝cute大,好厲害 12/17 13:38