Print Page | Close Window

Problem w/ Date in SQL Statement

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=28858
Printed Date: 28 March 2026 at 9:03am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Problem w/ Date in SQL Statement
Posted By: kennywhite
Subject: Problem w/ Date in SQL Statement
Date Posted: 16 September 2010 at 4:47pm
I am trying to view a list of reports that are more than 3 days old. Below is my SQL statement. When I open the page I see every report, not just ones that are more than 3 days old.

I am using MS Access as my database.

'Initialise the strSQL variable with an SQL statement to query the database DESCending order
strSQL = "SELECT * FROM orders WHERE CLOSED = false AND (Date_Entered >= #" & DateAdd ("d", 

-3, Date) & "#) AND IssueType LIKE 'Return' OR IssueType LIKE 'Product Discrepancy' ORDER BY 

orders.Date, orders.IssueType, orders.Receiver, orders.ID;"

Anyone know what I am doing wrong?

Thanks!



Replies:
Posted By: kennywhite
Date Posted: 20 September 2010 at 8:40pm
After getting away from the problem for a few days I was able to look at it with fresh eyes and see my simple errors. My new SQL statement is:
'Initialise the strSQL variable with an SQL statement to query the database DESCending order
strSQL = "SELECT * FROM orders WHERE CLOSED = false AND IssueType LIKE 'Product Discrepancy' 

AND (Date_Entered <= #" & DateAdd ("d", -3, Date) & "#)  OR CLOSED = false AND IssueType LIKE 

'Return' AND (Date_Entered <= #" & DateAdd ("d", -3, Date) & "#) ORDER BY orders.Date_Entered, 

orders.IssueType, orders.Receiver, orders.ID;"


Posted By: 123Simples
Date Posted: 22 September 2010 at 7:52pm
So it is all working Thumbs Up

-------------
http://www.123simples.com/" rel="nofollow - Visit 123 Simples Web Design


Posted By: kennywhite
Date Posted: 22 September 2010 at 7:57pm
Sure is!
:D



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net