Solved

Date Criteria in Access Query

Posted on 2016-07-25
3
37 Views
Last Modified: 2016-07-25
I need to set a date criteria in my query but not sure how to set it up. I need it to be between the current date and the same date last year so it captures a rolling year date range. Any ideas on how I would set this up as the criteria?
0
Comment
Question by:Lawrence Salvucci
3 Comments
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 41727577
Hi,

pls try

Between DateAdd("yyyy",-1,Date()) + 1 And Date())

Regards
0
 
LVL 1

Author Closing Comment

by:Lawrence Salvucci
ID: 41727582
Perfect! Thank you very much!
0
 
LVL 14

Expert Comment

by:wsh2
ID: 41727591
Dim strSQL as String
strSQL = _
    "SELECT * " & _
    "  FROM [MyTable] " & _
    " WHERE [MyTable].[MyDate] >= #12/31/2014# " & _
    "   AND [MyTable].[MyDate] <= #04/22/2015# "

Open in new window


OR

Dim dte1st as Date: dte1st = #12/31/2014#
Dim dte2nd as Date: dte2nd = #04/22/2015#
Dim strSQL as String
strSQL = _
    "SELECT * " & _
    "  FROM [MyTable] " & _
    " WHERE [MyTable].[MyDate] >= #" & dte1st & "# " & _
    "   AND [MyTable].[MyDate] <=  #" & dte2nd & "# "

Open in new window

0

Featured Post

Free Trending Threat Insights Every Day

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.

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

747 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

12 Experts available now in Live!

Get 1:1 Help Now