How to set monday as first day of week in SQL Server

Clipper87 picture Clipper87 · Nov 17, 2013 · Viewed 55.8k times · Source

I am running SQL Server 2008 on a machine with regional settings that have Monday as the first day of the week. If I create a computed column in a table to compute the day of week for a date field then I get 2 for a Monday date instead of 1.

Is there some property for the table or database or server that I need to set ?

Answer

Sam picture Sam · Nov 17, 2013

The first day of the week is based on your language settings of the server. The default setting for us_english is 7 (Sunday)

You can find the current first day of the week by using SELECT @@DATEFIRST


However, you can use DATEFIRST for this. Just put it at the top of your query

SET DATEFIRST 1; this sets Monday to the first day of the week for the current connection.

http://technet.microsoft.com/en-us/library/ms181598.aspx