Set First Day of the Week Globally

The first day of the week varies in different culture, e.g. in US, Sunday is the first day of the week, in Great Briton, it is the Monday. SQL Server has a command to set first day of the week:
 
SET DATEFIRST { number | @number_var }
number or @number_var  must be between 1 and 7, where 1 is the Monday and 7 is the Sunday.
 
This command is a run time setting, i.e. it changes this setting only for the current session. SQL Server does not provide a way to change this globally. What you can do is to define a SQL Server login, and assign the default language that has the first day of the week as you required. If your application use this account to connect to SQL Server, it will get the first day of the week setting you wanted. E.g. you have users from US and Great Briton. You can define two logins: USUser with the default language of us_english and the BrUser with the default language of British. Your application connects to the database by USUser for US users and by BrUser for the Briton users. In this way, users from both contries get the valid firts day of week setting.
You can check the first day of the week for each language by:
sp_helplanguage
To check the current settings, execute:
SELECT @@DATEFIRST
 
 
Advertisements
This entry was posted in SQL server. Bookmark the permalink.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s