Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Problem w/ Date in SQL Statement
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Problem w/ Date in SQL Statement

 Post Reply Post Reply
Author
kennywhite View Drop Down
Groupie
Groupie


Joined: 26 February 2009
Location: Indy
Status: Offline
Points: 106
Post Options Post Options   Thanks (0) Thanks(0)   Quote kennywhite Quote  Post ReplyReply Direct Link To This Post Topic: Problem w/ Date in SQL Statement
    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!


Edited by kennywhite - 16 September 2010 at 4:59pm
Back to Top
kennywhite View Drop Down
Groupie
Groupie


Joined: 26 February 2009
Location: Indy
Status: Offline
Points: 106
Post Options Post Options   Thanks (0) Thanks(0)   Quote kennywhite Quote  Post ReplyReply Direct Link To This Post 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;"
Back to Top
123Simples View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 July 2007
Location: United Kingdom
Status: Offline
Points: 1192
Post Options Post Options   Thanks (0) Thanks(0)   Quote 123Simples Quote  Post ReplyReply Direct Link To This Post Posted: 22 September 2010 at 7:52pm
So it is all working Thumbs Up
Back to Top
kennywhite View Drop Down
Groupie
Groupie


Joined: 26 February 2009
Location: Indy
Status: Offline
Points: 106
Post Options Post Options   Thanks (0) Thanks(0)   Quote kennywhite Quote  Post ReplyReply Direct Link To This Post Posted: 22 September 2010 at 7:57pm
Sure is!
:D
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.