473,395 Members | 1,639 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,395 software developers and data experts.

SQL server VS2005 Between Date problem

I am facing problem while fetching a data from SQL server DB

below is a query i'm executing
Expand|Select|Wrap|Line Numbers
  1. select * from Customer where(OrderDate BETWEEN '02/01/2012' and '14/01/2012') and (Item='Dell')
This query was working correct 2 days back but today i executed the same query and showing below error

"The Conversion of char datatype to a datetime datatype resulted in an out-of-range datetime value"

IN MY Sql Database i'm using Datatype datetime to store dates
Jan 14 '12 #1
2 1846
C CSR
144 100+
Should your output be 01/02/2012 and 01/14/2012? There is no 14th month. If your data is wrong, check your input.
Jan 14 '12 #2
NeoPa
32,556 Expert Mod 16PB
Monty Sing:
This query was working correct 2 days back but today I executed the same query and showing below error
No. It wasn't. You simply failed to realise it was getting the dates wrong. What you intended as 12th Jan was interpreted (correctly. Your code is where the error is) as 1st Dec.

Your SQL code is being created somewhere, no doubt, and this is getting the dates wrong. SQL dates are not region dependent. They recognise a general (ANSI-92) SQL standard format hich is m/d/y, regardless of where in the world your SQL is running. Hence, your code should be :
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM [Customer] WHERE ([OrderDate] BETWEEN '1/2/2012' AND '1/14/2012') AND ([Item]='Dell')
assuming your date range is 2nd Jan 2012 to 14th Jan 2012. Whatever code you have that creates this string should also be amended to reflect this change.
Jan 17 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Dominique Javet | last post by:
Hello, I'm new to php and mysql and I use Dreamweaver MX 2004, so sorry for this "newbie" question... I've found no answer in the forum ... I've a date problem with my formular. In my mysql DB...
2
by: F | last post by:
Hi All I am facing the most common problem of date where system date is different and SQL server dateformat is different. How I can change Date fomat in SQL server from US to UK format vis...
6
by: Jerome | last post by:
Hi, I know this is an old problem and I've already tried to look the solution up on the web but I didn't find what I need. So, there's the following situation: I've got an ASP page with a...
5
by: George Copeland | last post by:
This is a request for help fixing a SQL Server 2000/ADO problem on Windows XP. I would appreciate any useful assistance. PROBLEM: SQL Server access on my machine fails as follows: 1. All of...
1
by: pinos | last post by:
when i install the SQL server 2005, it occured the follow message: Product: Microsoft SQL Server 2005 CTP -- Error 29628. The setup has encountered an unexpected error in datastore. The action is...
0
by: Cantekin Guneser | last post by:
i am pumping some data from one database to other, program takes table form first database but when i insert to second database date shows 01 01 1900, i checked everything date comes true from...
2
by: Vaap | last post by:
I did lot of googling to see if I can solve the SQL server not found problem while trying to run ASP.Net community starter kit from an XP machine to Windows 2003 server hosting SQL server 2000...
3
by: Han | last post by:
Hi In debug mode, my asp.net page works under port: 13064 which is automatically set by the program. However when I browse to my asp.net page without the port number, error. How can I set the...
4
by: franco | last post by:
I am a beginner in programming. How can I display the system date - 5 December 2005 in my webpage.
1
by: suresh_nsnguys | last post by:
Hi, I am new to this Web dowmain.I am little bit confused with this functionality.I am looking forward some sugggesstion from you. Issue: Users allowed to create Ads in my application...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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:
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...

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.