How to get Previous business day in a week with that of current Business Day using sql server

后端 未结 8 2176
情歌与酒
情歌与酒 2020-12-14 09:00

i have an ssis Package which runs on business days (mon-Fri). if i receive file on tuesday , background(DB), it takes previous business day date and does some transactions.

8条回答
  •  忘掉有多难
    2020-12-14 09:50

    More elegant:

    select DATEADD(DAY, 
    CASE when datepart (dw,Getdate()) < 3 then datepart (dw,Getdate()) * -1 + -1 ELSE -1 END,
    cast(GETDATE() as date))
    

提交回复
热议问题