views:

357

answers:

2

With reference to http://stackoverflow.com/questions/280597/problem-with-date-daymonth-reversing-on-save

I have further noted that even setting the Session.LCID on the page itself is making no difference what so ever.

How could the environments be such that between test and live the asp site on live is reversing dates entered via SQL but not on test.

Both have the IUSR set to UK, both have all users set to UK, both have the SQL Account set to US English and both have Session.LCID set to 3081 (Australian English)

Why is test running " insert into datecolumn values '01/03/2008' and inserting '01/03/2008' and live is inserting '03/01/2008' "

The setups look totally identical. This must be figured out soon i'm getting quite scared that we'll never know. The problem is we may not change code or anything else. All I can do is investigate and tell them the cause. But I can't find it!

It's VB6/ASP and it's driving me do lally.

Access to the database is via a System DSN configured to use the correct SQL account.

What other info might you need.

+1  A: 

In SQL Server Management Studio, in Security - Logins, right-click the user you're connecting as and click 'Properties'. The bottom combo box is marked 'Default language', change this to "British English" (not just "English").

sp_configure 'default language' sets the default language for newly created logins, and it is this that is stored in sysconfigures.

I'm assuming here that the language isn't being set in the query string?

Sunlight
The problem here is that it is set to English on test which I know is US and it's set to English on Live. The two environments should be identical but they are behaving differently and I need to ascertain why. I can't make changes.
Robert
Well, if it's set to American English on test, it should be reversing dates... so it's test that's wrong, surely?Try SELECT @@LANGUAGE SELECT CAST('01/02/03' AS datetime)from Management Studio.
Sunlight
Doesn't matter which ones wrong persay. Test was setup to mimic live and this problem has only started occuring this week and so it's a change to live. Which no one is authoried to do. I need to 'fix' it then try and identify who made the change. But for the life of me I can't see the cause.
Robert
SELECT @@LANGUAGE SELECT CAST('01/02/03' AS datetime) returns the same results on test and live us_english and 2003-01-02
Robert
I know you'd think it should be reversing the dates but dam it, it only started doing that very recently and only on live and supposedly 'nothing' has changed. Maybe it's to do with how IIS picks the locale to use for IUSR after a reboot. The server was rebooted not long before this was occuring.
Robert
I've further discovered the SQL passed on test and live is identical and the date is an american format when passed to the DB. Test loads it correctly and live does not. The db account used is set to us_english in both cases.
Robert
A: 

I encourage you to modify the code that interacts with the database. There are 2 unambiguous date formats that you can use with SQL Server.

You can use yyyy-mm-ddThh:mi:ss.mmm or YYYYMMDD hh:mi:ss.mmm

SQL Server will never mis-interpret dates if you use one of the 2 formats listed above.

In vb, you can use the following format function to format the date in to an un-ambiguous date format that SQL Server will never mis-interpret.

Format(YourDateVariable, "yyyymmdd hh:nn:ss")
G Mastros
Sadly Robert has stated in two separate posts now that he can't modify the code that has been deployed...
Cirieno