Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have an instance of SQL server 2000 (8.0.2039) with a rather simple table. We recently had users complain about an application I wrote returning bad values for some of the dates in the databse. When I query the table directly via Server Management Studio, it will return the correct values, however the identical queries from my application report the wrong values, but only for a couple of dates.

I have been over the code, and it is solid. If the error was in the code, all of the dates reported should be wrong. I have also run the code on an identical test database, and everything is reported properly. I believe the problem may lie in the sql instance itself, which is why I am posting in Server Fault.

My question is, has anyone heard of a database reporting bad (incorrect) date values when queried via web application? It should be noted that this particular server was once manually rebuilt after having a cluster clean run on it.

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

Any issues with dates are related to locale and region usually.

That is, what is "05/02/2011": 5th February or 2nd March?

This usually happens when dates are stored as strings not as dates, or the local client settings are different (say someone has US English when you expect UK English).

You won't get incorrect date sometimes

share|improve this answer
    
Right you are! Your answer lead me down the correct troubleshooting path. Thanks so much! –  Ben Feb 5 '11 at 22:03
add comment

This isn't your problem, but I'll throw it out there for future people that run across this. With SQL Server 2000 it is possible to get invalid dates stored in a datetime column. I've seen dates with three digit months, or three digit days, etc. There are a couple of bugs which allow for data corruption which won't be caught by DBCC CHECKDB under SQL Server 2000. If/when the database is updated to SQL Server 2005 these problems will be caught and repaired, but under SQL Server 2000 you would need to manually fix the date rows or just live with them.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.