dbTalk Databases Forums  

YYYY-MM-DD not working in UK

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss YYYY-MM-DD not working in UK in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Ted Johnson
 
Posts: n/a

Default YYYY-MM-DD not working in UK - 07-25-2003 , 10:26 AM






The following query works fine against SQL Server 2000 here in the US:

SELECT * from TNEWSARTICLES where CreatedOn < '2003-04-25 14:22'

But in the UK, it returns this error:

80040e07: The conversion of a char data type to a datetime data type
resulted in an out-of-range datetime value

If I change the format to YYYY-DD-MM, then it does work in the UK. But
I was under the impression that the YYYY-MM-DD format will work
regardless of regional date format settings. Is this wrong?

Any help is appreciated
Ted

Reply With Quote
  #2  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: YYYY-MM-DD not working in UK - 07-25-2003 , 05:23 PM






Ted Johnson (t.google (AT) wjohnson1 (DOT) com) writes:
Quote:
The following query works fine against SQL Server 2000 here in the US:

SELECT * from TNEWSARTICLES where CreatedOn < '2003-04-25 14:22'

But in the UK, it returns this error:

80040e07: The conversion of a char data type to a datetime data type
resulted in an out-of-range datetime value

If I change the format to YYYY-DD-MM, then it does work in the UK. But
I was under the impression that the YYYY-MM-DD format will work
regardless of regional date format settings. Is this wrong?
Yes. YYYY-MM-DD may work well in ODBC regardless of regional settings.
But in SQL Server the safe format is YYYYMMDD. You can also use
YYYY-MM-DDTHH:MM:SS where T stands for itself. YYYY-MM-DD is not safe
in SQL Server.


--
Erland Sommarskog, SQL Server MVP, sommar (AT) algonet (DOT) se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp


Reply With Quote
  #3  
Old   
Ted Johnson
 
Posts: n/a

Default Re: YYYY-MM-DD not working in UK - 07-28-2003 , 10:37 AM



Thanks, I was (wrongly) assuming the the time portion could be omitted
while using YYYY-MM-DD.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Reply With Quote
  #4  
Old   
Tony Hodgson
 
Posts: n/a

Default Re: YYYY-MM-DD not working in UK - 07-29-2003 , 10:47 AM



Erland Sommarskog <sommar (AT) algonet (DOT) se> wrote

Quote:
Ted Johnson (t.google (AT) wjohnson1 (DOT) com) writes:
The following query works fine against SQL Server 2000 here in the US:

SELECT * from TNEWSARTICLES where CreatedOn < '2003-04-25 14:22'

But in the UK, it returns this error:

80040e07: The conversion of a char data type to a datetime data type
resulted in an out-of-range datetime value

If I change the format to YYYY-DD-MM, then it does work in the UK. But
I was under the impression that the YYYY-MM-DD format will work
regardless of regional date format settings. Is this wrong?

Yes. YYYY-MM-DD may work well in ODBC regardless of regional settings.
But in SQL Server the safe format is YYYYMMDD. You can also use
YYYY-MM-DDTHH:MM:SS where T stands for itself. YYYY-MM-DD is not safe
in SQL Server.
You could also use convert(varchar(8), CreatedOn, 112) to omit the
time part and return the date in the format 'YYYYMMDD'. This saves
the > and < functions when searching for dates.

Hodge


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.