Passing date as a parameter

A

Armando Méndez

I need to perform the following query to an SQL database

SELECT Id, Date
FROM dbo.Table
WHERE (Date >= ::Date1::) AND (Date <= ::Date2::)

Where ::Date1:: and ::Date2:: are input data fields in my form

Whenever I use parameters in the query fails.
if I run the query without parameters works Ok, like in:

SELECT Id, Date
FROM dbo.Table
WHERE (Date >= '11/01/07' AND (Date <= '11/15/07' )

I´m using Frontpage 2003, MS SQL 2005, Win 2003, IIS6

Any ideas?
 
S

Stefan B Rusynko

Date is a reseved name and can NOT be used for a DB field name
- Change your DB field name for "Date" to say "CkDate"

I don't use the wizards, but hand coding ASP requires date delimiters

strSql="SELECT Id, CkDate FROM dbo.Table WHERE (Date>=#" & Date1 & "#) AND (Date<=#" & "Date2 #)"


--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


|I need to perform the following query to an SQL database
|
| SELECT Id, Date
| FROM dbo.Table
| WHERE (Date >= ::Date1::) AND (Date <= ::Date2::)
|
| Where ::Date1:: and ::Date2:: are input data fields in my form
|
| Whenever I use parameters in the query fails.
| if I run the query without parameters works Ok, like in:
|
| SELECT Id, Date
| FROM dbo.Table
| WHERE (Date >= '11/01/07' AND (Date <= '11/15/07' )
|
| I´m using Frontpage 2003, MS SQL 2005, Win 2003, IIS6
|
| Any ideas?
|
|
 
R

Ronx

I don't work with SQL server, so this could be wrong.
Try
SELECT Id, Date
FROM dbo.Table
WHERE (Date >= '::Date1::') AND (Date <= '::Date2::')
 

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

Top