My WHERE clause is not filtering dates properly

Posted on 2010-01-08
Last Modified: 2012-05-08
I have a query I am building that needs a WHERE clause to filter dates. It does not seem to be working, and I cannot understand why. Can someone please tell me what I am doiing wrong.

Below is the code of the Query and then the rsults, which shows two values that I believe should be filtered out.
SELECT DAFifteenthStPanelFPY.WeekEndingDate, DAFifteenthStPanelFPY.SumOfInspected

FROM DAFifteenthStPanelFPY

WHERE DAFifteenthStPanelFPY.WeekEndingDate > 4/01/2008

ORDER BY DAFifteenthStPanelFPY.WeekEndingDate;

Open in new window

Question by:Rex85
    LVL 92

    Accepted Solution

    You have to qualify your dates:

    SELECT DAFifteenthStPanelFPY.WeekEndingDate, DAFifteenthStPanelFPY.SumOfInspected
    FROM DAFifteenthStPanelFPY
    WHERE DAFifteenthStPanelFPY.WeekEndingDate > #4/01/2008#
    ORDER BY DAFifteenthStPanelFPY.WeekEndingDate;

    Author Comment

    That worked. Thank you. Can you tell me what that means though?

    Author Closing Comment

    Thank you very much.

    LVL 92

    Expert Comment

    by:Patrick Matthews
    Access and VBA both use the # symbol to qualify dates; without it, they will interpret 4/1/2008 as:

    "4 divided by 1 divided by 2008"

    Author Comment

    Ah...Thank you very much. I tried quotes, but that made it think it was text of course. Thanks again.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    Title # Comments Views Activity
    select query - oracle 16 57
    Sql code problem 6 12
    Running a procedure from anothe unrelated form 5 22
    Printing Problem 13 21
    I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
    Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
    Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
    What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now