Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Old Forums
 CLOSED - General SQL Server
 Server locale error

Author  Topic 

cliff
Starting Member

2 Posts

Posted - 2005-10-19 : 08:58:14
I have just re-started my SQL 2000 server SP3 (No changes just a re-start) and now I can only enter dates through ASP pages in US format i.e. mm/dd/yyyy, previously UK dd/mm/yyyy had been working fine.

Server OS is English UK through and through.

Oddly enough if I use an ASP quesry getdate() to insert into a field, the date is in UK format! The global.asa has the correct UK LCID set also.

I tracked down a useful ASP script to test this and the result was as follows....

US English passed.
UK English failed. [Microsoft][ODBC SQL Server Driver][SQL Server]The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

US English unaltered: 10/19/2005 1:33:08 PM
US English altered: 10/19/2005 1:33:08 PM

UK English unaltered: 10/19/2005 1:33:08 PM
UK English altered: 19/10/2005 13:33:08

Can the SQL server locale be set independant of the server OS?

Another possibility is that the SQL server sets itself to the locale of the first received request, does this sound feasable?

Any help appreciated.

Regards

Cliff.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-19 : 09:03:21
Always send your dates from your Presentation Layer in the Format yyyymmdd to avoid this error

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

cliff
Starting Member

2 Posts

Posted - 2005-10-19 : 10:31:48
Cheers Madhivanan

I appreciate the "best practice" and yes it does work!

I think the ASP script test result is a red hearing, tried it on a SQL server functioning as expected with the same result.

Still confused as to why but the solution will work, cheers.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-19 : 10:36:15
yyyymmdd is the ISO Date Format so that it will work for any local settings

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -