Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL-Server DATE COMPATIBILITY ACROSS RELEASES MYSTERY

Status
Not open for further replies.

bawtry

Programmer
Jul 17, 2001
8
GB

OH YES! YET ANOTHER DATE CONVERSION PROBLEM.
Can anybody explain this mystery? ...

Query issued by client system:
VERSION ISO: UPDATE tblPatientDetails SET Dob = '1948-06-25'
VERSION USA: UPDATE tblPatientDetails SET Dob = '1948-25-06'

SERVER 1: (as reported by @@Version)
Microsoft SQL Server 7.00 - 7.00.623 (Intel X86) Nov 27 1998
MSDE on Windows 4.10 (Build 1998)

RESULT: VERSION ISO runs OK
RESULT: VERSION USA fails with error 242


SERVER 2: (as reported by @@Version)
Microsoft SQL Server 2000 - 8.00.194 (Intel X86) Aug 6 2000
Personal Edition on Windows NT 4.00 (Build 1381 : Service Pack 6)

RESULT: VERSION ISO fails with error 242
RESULT: VERSION USA runs OK

Notes:
1. Both server DB's have 'default language' set to 23. (UK English)
2. Error 242 is "the conversion of a char datatype to a datetime datatype
resulted in an out-of-range datetime value".

Is there something beyond 'default language' that affects date handling in SQL Server?
Why don't Microsoft first honour the ISO standard date before trying to guess at the
string format when converting to datetime (this would make life so much simpler)?
How does one construct dates in queries that will be handled consistently by
multiple SQL Server databases?

(I suspect this is the same question as Thread183-94972 from MarathonMan which
has not received a satisfactory answer - yet.)

Anybody help?
 
Can't explain it - but I always tell my programmers to either pass the date as 'DD MMM YYYY' e.g. '01 JAN 2001' if they have to pass it as a string, or else use ADO date parameters, and pass it as a date (from VB or ASP).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top