Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with a query

Status
Not open for further replies.
Feb 3, 2003
28
0
0
US
I'm trying to find all items in my db that are active and where the expire_date is either today's date or in the future and then sort them by category.
Finding anything that is active and sorting by category works fine. It's the date part that isn't wokring for me. The format of the date is MM/DD/YYYY

Here is query

SELECT * FROM Items WHERE active=True AND expire_date>=" & Date & " ORDER BY category

I'm using this in a Active Server Page. That is why there is the " & Date & " in the statement.
So what am i missing?
 
use ASP to display the sql string just before it is executed

i want to see if you have included the singlequotes around the date literal when the ASP value Date is substituted

because if it turns out to be

... AND expire_date >= 10/30/2003

then that is 10 divided by 30 divided by 2003 which equates to 0

and that's probably why it's not working ;)


rudy
 
Crap, I never thought about it until you said it... you were right. After some messing around the final/working query is

SELECT * FROM Items WHERE active=True AND expire_date>=#" & Date & "# ORDER BY category

It's now doing everything the way I wanted.

Thanks!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top