How to Get Non Weekend Dates

Give you a given date, how to find out whether it is a weekend date. You may start with with DATEPART(dw, GETDATE()). Due to the different environment with SET LANGUAGE, you may have different SETFIRST value.
But if you can use a calculation to include this datefirst difference, you can get a solution that works for all environments.
(DATEPART(dw, getdate())+@@DATEFIRST)%7 not in (0,1).

An example to use this:

Select * from yourtable where (DATEPART(dw, dtColumn)+@@DATEFIRST)%7>1


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s