Date query problem in DRW

T

Targa

This is driving me nuts!

What is wrong with this code?

var1 = request.QueryString
"SELECT ID,lname,fname FROM Schedule WHERE Sched_Date = #" & var1 & "# "

or even this one:
"SELECT ID,lname,fname FROM Schedule WHERE Sched_Date = #" &
request.QueryString & "# "

I keep getting "Syntax error in date in query expression"

The querystring is in proper date format when I do
reposne.write request.QueryString

FP2002, IIS5, Access 2002

Thanks in advance,
Mike
 
T

Thomas A. Rowe

Is the querystring sending a valid date string?

Try this in place of your request.QueryString:

var1 = Date()

Just for testing with the file one listed.

--

==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle,
MS KB Quick Links, etc.
==============================================
 
T

Targa

Yes. The querystring is actually coming from a calendar component.

response.write var1

result: 2/28/2004
 
T

Thomas A. Rowe

Ok, then check the database field to be sure that it is a date field, set to
short date.

--

==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle,
MS KB Quick Links, etc.
==============================================
 
T

Targa

It is.

Actually, it works when I use an actual variable name like this:
SELECT ID,lname,fname FROM Schedule WHERE Sched_Date = #::Date1::# "

My problem is that I have to capture a query from 1 of 3 different links:

mypage.asp?Date1=2/28/2004
mypage.asp?Date2=3/28/2004
mypage.asp?Date3=4/28/2004

That's why Im trying to use the Request.QueryString

Maybe there's a better way to acheive this?

Thanks!
 
T

Thomas A. Rowe

Sorry, I didn't notice that you Request.QueryString didn't contain a source
name.

If the data value will only be submitted individually, then you can past
them all using the same source name.

--

==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle,
MS KB Quick Links, etc.
==============================================
 
T

Targa

I have no control over the source name as its .dll component.
Its a calendar component in which Im displaying 3 months at a time.

Each instance has its own source name.

Maybe time to find a new calendar?

Thanks for your help,
Mike
 
T

Thomas A. Rowe

Try this:

<%
Var1 = Request.QueryString("Date1")
Var2 = Request.QueryString("Date2")
Var3 = Request.QueryString("Date3")

If Var1 > 0 then
varDate = Request.QueryString("Date1")
End If
If Var2 > 0 then
varDate = Request.QueryString("Date2")
End If
If Var3 > 0 then
varDate = Request.QueryString("Date3")
End If
%>

You could also do this using ElseIf and Else, I just perfer not to..
--

==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle,
MS KB Quick Links, etc.
==============================================
 
T

Thomas A. Rowe

Correction:

<%
If Trim(Request.QueryString("Date1")) > " " then
varDate = Trim(Request.QueryString("Date1"))
End If
If Trim(Request.QueryString("Date2")) > " " then
varDate = Trim(Request.QueryString("Date2"))
End If
If Trim(Request.QueryString("Date3")) > " " then
varDate = Trim(Request.QueryString("Date2"))
End If
%>
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle,
MS KB Quick Links, etc.
==============================================
 
T

Targa

Then Im back to my original problem - pulling the var into my select
statement:
"SELECT ID,lname,fname FROM Schedule WHERE Sched_Date = #" & varDate & "# "

Still throws the syntax error in date query.
 
T

Thomas A. Rowe

Can you zip a copy of your database and all page and email me?

--

==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle,
MS KB Quick Links, etc.
==============================================
 

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