Link to home
Create AccountLog in
Avatar of Larry Brister
Larry BristerFlag for United States of America

asked on

Current Business Day of Month

Is there a function that shows me what business day of the month the current day is?

We work 5 days a week at my company

So..
If today is 11/14/2012 the function would return that it is the 10th business day of the month
Avatar of Qlemo
Qlemo
Flag of Germany image

This is the formula, coded as select for easy testing.
set datefirst 7

declare @dt datetime
set @dt = '20121114'

select day(@dt)- datediff(wk, @dt - day(@dt), @dt)*2 - case datepart(dw, @dt) when 7 then 1 else 0 end

Open in new window

This works if start of week = 7 = Sunday. For any other @@datefirst you need to adapt the 7 to the weekday number of Saturday.
SOLUTION
Avatar of Rimvis
Rimvis
Flag of Lithuania image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
ASKER CERTIFIED SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Larry Brister

ASKER

Thanks guys