[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 80
  • Last Modified:

Date Criteria in Access Query

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
Lawrence Salvucci
Asked:
Lawrence Salvucci
1 Solution
 
Rgonzo1971Commented:
Hi,

pls try

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

Regards
1
 
Lawrence SalvucciInformation Technology ManagerAuthor Commented:
Perfect! Thank you very much!
0
 
wsh2Commented:
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now