ASP SQL query error with data types

D

David McManus

I am trying to use a query to filter SQL Server 2000 records by a date
value.
Here is relevant columns in my database table (tblContent):

title [nvarchar]
starting [smalldatetime]

.... and here is my query:

Query = "SELECT title FROM tblContent WHERE starting = '" & date & "'"

I've done exactly this query on numberous occassions in the past with no
problems at all but this time I get the following error:

Microsoft OLE DB Provider for ODBC Drivers (0x80040E07)
[Microsoft][ODBC SQL Server Driver][SQL Server]The conversion of char data
type to smalldatetime data type resulted in an out-of-range smalldatetime
value.

What on earth is going on? I'm not using a char data type anywhere! I am
doing all the initial development locally and I have just installed XP
Service Pack 2. I realise it's unlikely, but that's the only thing I can
possibly attribute it to. Or am I just missing something obvious?

Anyone able to help, please?
Thanks.
 
M

Meelis Lilbok

Hi

Use this date format and no problems

yyyymmdd

Query = "SELECT title FROM tblContent WHERE starting = '" & date & "'"

where date='yyyymmdd'


Mex
 
D

David McManus

Confused....

Could you tell me precisely where in my query you mean, please?

D

Meelis Lilbok said:
Hi

Use this date format and no problems

yyyymmdd

Query = "SELECT title FROM tblContent WHERE starting = '" & date & "'"

where date='yyyymmdd'


Mex



David McManus said:
I am trying to use a query to filter SQL Server 2000 records by a date
value.
Here is relevant columns in my database table (tblContent):

title [nvarchar]
starting [smalldatetime]

... and here is my query:

Query = "SELECT title FROM tblContent WHERE starting = '" & date & "'"

I've done exactly this query on numberous occassions in the past with no
problems at all but this time I get the following error:

Microsoft OLE DB Provider for ODBC Drivers (0x80040E07)
[Microsoft][ODBC SQL Server Driver][SQL Server]The conversion of char
data type to smalldatetime data type resulted in an out-of-range
smalldatetime value.

What on earth is going on? I'm not using a char data type anywhere! I am
doing all the initial development locally and I have just installed XP
Service Pack 2. I realise it's unlikely, but that's the only thing I can
possibly attribute it to. Or am I just missing something obvious?

Anyone able to help, please?
Thanks.
 
B

Bob Barrows [MVP]

http://www.aspfaq.com/show.asp?id=2313 vbscript
http://www.aspfaq.com/show.asp?id=2040 help with dates
http://www.aspfaq.com/show.asp?id=2260 dd/mm/yyy confusion

Bob Barrows

David said:
Confused....

Could you tell me precisely where in my query you mean, please?

D

Meelis Lilbok said:
Hi

Use this date format and no problems

yyyymmdd

Query = "SELECT title FROM tblContent WHERE starting = '" & date &
"'"

where date='yyyymmdd'


Mex



David McManus said:
I am trying to use a query to filter SQL Server 2000 records by a
date value.
Here is relevant columns in my database table (tblContent):

title [nvarchar]
starting [smalldatetime]

... and here is my query:

Query = "SELECT title FROM tblContent WHERE starting = '" & date &
"'"

I've done exactly this query on numberous occassions in the past
with no problems at all but this time I get the following error:

Microsoft OLE DB Provider for ODBC Drivers (0x80040E07)
[Microsoft][ODBC SQL Server Driver][SQL Server]The conversion of
char data type to smalldatetime data type resulted in an
out-of-range smalldatetime value.

What on earth is going on? I'm not using a char data type anywhere!
I am doing all the initial development locally and I have just
installed XP Service Pack 2. I realise it's unlikely, but that's
the only thing I can possibly attribute it to. Or am I just missing
something obvious?

Anyone able to help, please?
Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,588
Members
45,100
Latest member
MelodeeFaj
Top