473,399 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

YYYY-MM-DD not working in UK

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
Jul 20 '05 #1
3 8881
Ted Johnson (t.******@wjohnson1.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.
--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2
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!
Jul 20 '05 #3
Erland Sommarskog <so****@algonet.se> wrote in message news:<Xn*********************@127.0.0.1>...
Ted Johnson (t.******@wjohnson1.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
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: teho | last post by:
Hello, I am new to PHP and I am wondering how can I set index.php to default url when accessing my site. Eg. http://www.yyyy.com/ will access the file http://www.yyyy.com/index.php. And how...
4
by: Prakash | last post by:
Hi Can anyone tell me how to derive "yyyy" from a timestamp column in db2? Something like to_char(sysdate, 'yyyy') ... in oracle. I have to oracle-like to_char function but its very slow. If...
0
by: PMB | last post by:
Thank you in advance for any and all assistance. I would like to know how I can close out a Query/Table and Create a Table with the year? I want to be able to create a table with saved data and...
1
by: Rob | last post by:
How can I create a validation rule for only allowing two specific dates but with variable years: 1/1/yyyy or 12/1/yyyy so only the dates 1/1/2004 or 1/1/1999 or 12/1/2001 etc. I tried...
5
by: jomonto | last post by:
Hello- I've looked at all the age calulation solutions - but I'm a little stumped on how to set this one up. Here is what I need to do. I need to find all the kids in my DB that are currently...
3
by: Lee Chapman | last post by:
Hi, I have a problem where my ASP.NET application occasionally generates a MissingFieldException exception. This unexpectedly happened on my development box, and so I was able to extract some...
6
by: DavidOwens | last post by:
Sub PreviewReport_Click() On Error GoTo Err_PreviewReport_Click Dim stRepName As String: Rem Holds the Report name Dim stDispId As String: Rem Holds the Dispenser ID Dim...
3
by: Michael R | last post by:
Hello dear users and experts: In my current project I have a cross-tab query, with a row heading column being a date. I'm intersted for it to be sorted correctly, and it is: 04/2003, 05/2003,...
1
by: ambi21hs | last post by:
Hi i need a validation code in c for month in the mon-yyyy format 2 embed in between sql so any one help me out with this.. thank you
0
by: JB | last post by:
I am getting the above error message. I have an abstract class which defines a method like so: public abstract IContainer NewDal { get; } - Then I have a class which is implementing the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.