473,385 Members | 2,069 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,385 software developers and data experts.

Date problem in VB 2005 and SQL Server 2005

Hi!

I am using SQL Server 2005 express edition as backend and Visual Basic 2005 express edition as frontend. This question is related to date comparison.

SELECT IssueDate, Client, AgencyCode
FROM SPACEBOOKING
WHERE (IssueDate BETWEEN CONVERT(DATETIME, '2006-05-01 00:00:00', 102) AND CONVERT(DATETIME, '2006-05-31 00:00:00', 102)) AND (AgencyCode = 1595)
ORDER BY IssueDate


Above query is generated by query designer and it retrieves 16 records.

However, when I use this code in my vb 2005 application and instead of '2006-05-01 00:00:00', I use dtpicker1.value and instead of '2006-05-31 00:00:00' I use dtpicker2.value, it gives me the following error :

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

What is the problem and how to solve it?

My regional date setting id dd/mm/yyyy.
May 18 '07 #1
1 1604
jku
2
Hi!

I am using SQL Server 2005 express edition as backend and Visual Basic 2005 express edition as frontend. This question is related to date comparison.

SELECT IssueDate, Client, AgencyCode
FROM SPACEBOOKING
WHERE (IssueDate BETWEEN CONVERT(DATETIME, '2006-05-01 00:00:00', 102) AND CONVERT(DATETIME, '2006-05-31 00:00:00', 102)) AND (AgencyCode = 1595)
ORDER BY IssueDate


Above query is generated by query designer and it retrieves 16 records.

However, when I use this code in my vb 2005 application and instead of '2006-05-01 00:00:00', I use dtpicker1.value and instead of '2006-05-31 00:00:00' I use dtpicker2.value, it gives me the following error :

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

What is the problem and how to solve it?

My regional date setting id dd/mm/yyyy.
The date format code in your SQL is yy.mm.dd which is different to your regional setting of dd/mm/yyyy
May 18 '07 #2

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

Similar topics

3
by: Andrew DeFaria | last post by:
I have the following php code: function Today2SQLDatetime () { $today = date ("Y-m-d H:i:s"); print "date (\"Y-m-d H:i:s\") returned $today<br>"; return $today; return date ("Y-m-d H:i:s"); }...
7
by: What-a-Tool | last post by:
How does the expire date work setting it server side with asp. I know with javascript setting it client side it will be set to the clients local time, and therefore expire when the clients local...
7
by: Marc Pelletier | last post by:
Hello, I have a table with a Day field, defined as smalldatetime. I am filling it from a CSharp application with the following code: DataRow r = dtStaDays.NewRow(); r= station_ID; r =...
4
by: Byron | last post by:
Hi, I had a script set up to create a redirect until a certain date, and I left the script in there after that date thinking it would just be dormant until I changed the date parameters. To...
2
by: Franck | last post by:
Hi, 'm gettin mad about date conversion. Here is the point. Got and add-in for Excel which call functions from a web service (on a remote server) The remote server has regional settings...
10
by: Robert | last post by:
I would like to run a report for each month over two years. I am currently using a date range like this. Then manually substitute the error_time bounds for each month and rerun the query. How...
3
by: Larry Bertolini | last post by:
For some reason, I recall having read that SQL Server 2005 would support a datatype that represented date, but not time. (This would be useful for storing things like birthday, where you usually...
7
by: rcamarda | last post by:
I wish to build a table based on values from another table. I need to populate a table between two dates from another table. Using the START_DT and END_DT, create records between those dates. I...
10
by: Henrik Dahl | last post by:
Hello! I have an xml schema which has a date typed attribute. I have used xsd.exe to create a class library for XmlSerializer. The result of XmlSerializer.Serialize(...) should be passed as the...
9
by: ice | last post by:
Hello, I have a couple of tables. The client tables and the contacted tables. I am not sure how to start on this, what I need is a way to query all my clients then show any client that the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.