Query problem, Help!!! (MD WebsUnlimited.com or anyone!)

T

Test_1

Hello!

I have this query to be run from an .asp page (B.asp)
against an access database:

SELECT Orders.* FROM Orders
WHERE (Orders.Date between #::StartDate::# and
#::EndDate::#);

StartDate and EndDate are parameters captured as
character strings in Text Boxes on another .asp page, in
a form that posts to B.asp.

I receive this error:

[Microsoft][ODBC Microsoft Access Driver] Syntax error in
date in query expression '(Orders.Date between #1# and
#2#)'.

What's wrong in the syntax? is that the proper way to
typecast a character string as a Date?

Any help will be welcome. Thanks in advace!
 
D

David Berry

You're getting the error because you aren't passing an actual date as a
parameter. Ex: if you want to see dates between 1/1/04 and 2/1/04 then the
SQL statement would look like this:

SELECT Orders.* FROM Orders
WHERE (Orders.Date between #1/1/04# and #2/1/04#)

From the error it looks like the date is getting truncated at the first "/".
What's the code look like that gets the 2 parameters?
 
G

grw

"date" is a reserved word

SELECT Orders.* FROM Orders
WHERE ([Orders.Date] between #::StartDate::# and
#::EndDate::#);
 
M

MD WebsUnlimited.com

The text fields that StartDate and EndDate must be form fields that contain
actual dates, e.g., 01/01/03
 
M

MD WebsUnlimited.com

Huh?


--
Mike -- FrontPage MVP '97-'02
http://www.websunlimited.com
FrontPage Add-ins Since '97 2003 / 2002 / 2000 Compatible
----------------------------------------------------------------------------
--------------------
If you think I'm doing a good job, let MS know at (e-mail address removed)

grw said:
"date" is a reserved word

SELECT Orders.* FROM Orders
WHERE ([Orders.Date] between #::StartDate::# and
#::EndDate::#);



Test_1 said:
Hello!

I have this query to be run from an .asp page (B.asp)
against an access database:

SELECT Orders.* FROM Orders
WHERE (Orders.Date between #::StartDate::# and
#::EndDate::#);

StartDate and EndDate are parameters captured as
character strings in Text Boxes on another .asp page, in
a form that posts to B.asp.

I receive this error:

[Microsoft][ODBC Microsoft Access Driver] Syntax error in
date in query expression '(Orders.Date between #1# and
#2#)'.

What's wrong in the syntax? is that the proper way to
typecast a character string as a Date?

Any help will be welcome. Thanks in advace!
 
D

David Berry

In Access, if the Field is called "Date" then you need to put brackets
around it or ASP has fits. I didn't notice that but that's still not the
whole issue. I looks like the whole date isn't getting passed in.

--
David Berry - MCP
Microsoft MVP - FrontPage
FrontPage Support: http://www.net-sites.com/sitebuilder/
-----------------------------------

-----------------------------------

MD WebsUnlimited.com said:
Huh?


--
Mike -- FrontPage MVP '97-'02
http://www.websunlimited.com
FrontPage Add-ins Since '97 2003 / 2002 / 2000 Compatible
-------------------------------------------------------------------------- --
--------------------
If you think I'm doing a good job, let MS know at (e-mail address removed)

grw said:
"date" is a reserved word

SELECT Orders.* FROM Orders
WHERE ([Orders.Date] between #::StartDate::# and
#::EndDate::#);



Test_1 said:
Hello!

I have this query to be run from an .asp page (B.asp)
against an access database:

SELECT Orders.* FROM Orders
WHERE (Orders.Date between #::StartDate::# and
#::EndDate::#);

StartDate and EndDate are parameters captured as
character strings in Text Boxes on another .asp page, in
a form that posts to B.asp.

I receive this error:

[Microsoft][ODBC Microsoft Access Driver] Syntax error in
date in query expression '(Orders.Date between #1# and
#2#)'.

What's wrong in the syntax? is that the proper way to
typecast a character string as a Date?

Any help will be welcome. Thanks in advace!
 
M

MD WebsUnlimited.com

I use that query all the time and do not need any other brackets.

It looks like the fields that pass in the dates have the wrong values
entered.

--
Mike -- FrontPage MVP '97-'02
http://www.websunlimited.com
FrontPage Add-ins Since '97 2003 / 2002 / 2000 Compatible
----------------------------------------------------------------------------
--------------------
If you think I'm doing a good job, let MS know at (e-mail address removed)

David Berry said:
In Access, if the Field is called "Date" then you need to put brackets
around it or ASP has fits. I didn't notice that but that's still not the
whole issue. I looks like the whole date isn't getting passed in.

--
David Berry - MCP
Microsoft MVP - FrontPage
FrontPage Support: http://www.net-sites.com/sitebuilder/
-----------------------------------
To assist you in getting the best answers for FrontPage support see:
http://www.net-sites.com/sitebuilder/newsgroups.asp
-----------------------------------

MD WebsUnlimited.com said:
Huh?


--
Mike -- FrontPage MVP '97-'02
http://www.websunlimited.com
FrontPage Add-ins Since '97 2003 / 2002 / 2000 Compatible
--------------------------------------------------------------------------
--
--------------------
If you think I'm doing a good job, let MS know at (e-mail address removed)

grw said:
"date" is a reserved word

SELECT Orders.* FROM Orders
WHERE ([Orders.Date] between #::StartDate::# and
#::EndDate::#);



Hello!

I have this query to be run from an .asp page (B.asp)
against an access database:

SELECT Orders.* FROM Orders
WHERE (Orders.Date between #::StartDate::# and
#::EndDate::#);

StartDate and EndDate are parameters captured as
character strings in Text Boxes on another .asp page, in
a form that posts to B.asp.

I receive this error:

[Microsoft][ODBC Microsoft Access Driver] Syntax error in
date in query expression '(Orders.Date between #1# and
#2#)'.

What's wrong in the syntax? is that the proper way to
typecast a character string as a Date?

Any help will be welcome. Thanks in advace!
 
D

David Berry

Hmm. If I do it in straight ASP I get an error. Yes, I agree, it looks
like the value is getting cut off at the first slash. ie. instead of
passing 1/1/04 it's only getting the "1"

--
David Berry - MCP
Microsoft MVP - FrontPage
FrontPage Support: http://www.net-sites.com/sitebuilder/
-----------------------------------

-----------------------------------

MD WebsUnlimited.com said:
I use that query all the time and do not need any other brackets.

It looks like the fields that pass in the dates have the wrong values
entered.

--
Mike -- FrontPage MVP '97-'02
http://www.websunlimited.com
FrontPage Add-ins Since '97 2003 / 2002 / 2000 Compatible
-------------------------------------------------------------------------- --
--------------------
If you think I'm doing a good job, let MS know at (e-mail address removed)

David Berry said:
In Access, if the Field is called "Date" then you need to put brackets
around it or ASP has fits. I didn't notice that but that's still not the
whole issue. I looks like the whole date isn't getting passed in.

--
David Berry - MCP
Microsoft MVP - FrontPage
FrontPage Support: http://www.net-sites.com/sitebuilder/
-----------------------------------
To assist you in getting the best answers for FrontPage support see:
http://www.net-sites.com/sitebuilder/newsgroups.asp
-----------------------------------

MD WebsUnlimited.com said:

--------------------------------------------------------------------------
--
--------------------
If you think I'm doing a good job, let MS know at (e-mail address removed)

"date" is a reserved word

SELECT Orders.* FROM Orders
WHERE ([Orders.Date] between #::StartDate::# and
#::EndDate::#);



Hello!

I have this query to be run from an .asp page (B.asp)
against an access database:

SELECT Orders.* FROM Orders
WHERE (Orders.Date between #::StartDate::# and
#::EndDate::#);

StartDate and EndDate are parameters captured as
character strings in Text Boxes on another .asp page, in
a form that posts to B.asp.

I receive this error:

[Microsoft][ODBC Microsoft Access Driver] Syntax error in
date in query expression '(Orders.Date between #1# and
#2#)'.

What's wrong in the syntax? is that the proper way to
typecast a character string as a Date?

Any help will be welcome. Thanks in advace!
 

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