Ponnurangam


Hi All,

My week starts on Monday rather than on Sunday which is default(US, English) in SQL Server and would like to change the same so I would get proper weeknumber and dayindex using DATEPART.

I am looking at different ways of setting DATEFIRST(SET DATEFIRST 1) in SQL Server 2005.

I could set in a stored procedure, but this isn't a feasible way for me because I am using .nettiers to generate by business objects and stored procedures. I need to alter the sp's everytime I newly generate the code and sp's.

I couldn't set it in a function which I was hoping initially. I understand this datefirst is stored in one of the sys table in MASTER DB and I couldn't find a straight forward way to change this.

Can anyone suggest me a way to set the DATEFIRST either at a database level or at a server level(probably by changing the sys table in MASTER DB).

Any help on this would be greatly appreciated.

Ponnu

Trellisys.net




Re: Different ways to set DATEFIRST

Arnie Rowland


You 'could' set the default login Language to 'British'. But that would also make the default date format to be dmy instead of the US based mdy.

At your 'own risk', you may wish to explore changing the datefirst value (from 7 to 1) in the sys.syslanguages table.







Re: Different ways to set DATEFIRST

Ponnurangam

Hi Arnie,

Thanks for the help.

I couldn't change the default login language as I am passing the date in dmy in few places from .NET.

So looks like I need to look at changing the DATEFIRST value in the sys.syslanguages table. Can you please let me how to do the same in SQL Server 2005 and the implications of the same.

Thanks

Ponnu






Re: Different ways to set DATEFIRST

Arnie Rowland

This thread may help with your pursuit.

You 'hould' understand the implications.

Every built-in function or procedure that has anything to do with WeekDay calculations or determinations will be affected, including week of year.

Obviously, day of week determiniations, and most other datetime functions 'should NOT' be adversely affected.

BUT test, test, test.