Sqlserver
 sql >> Database >  >> RDS >> Sqlserver

Primo giorno lavorativo del mese corrente - SQL Server

Un'istruzione Simple case potrebbe farlo

SELECT CASE 
        WHEN DATENAME(WEEKDAY, dateadd(mm, DATEDIFF(MM, 0, getdate()), 0)) = 'Saturday'
            THEN dateadd(mm, DATEDIFF(MM, 0, getdate()), 0) + 2
        WHEN DATENAME(WEEKDAY, dateadd(mm, DATEDIFF(MM, 0, getdate()), 0)) = 'Sunday'
            THEN dateadd(mm, DATEDIFF(MM, 0, getdate()), 0) + 1
        ELSE dateadd(mm, DATEDIFF(MM, 0, getdate()), 0)
        END