Lawrence Salvucci
asked on
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Dim strSQL as String
strSQL = _
"SELECT * " & _
" FROM [MyTable] " & _
" WHERE [MyTable].[MyDate] >= #12/31/2014# " & _
" AND [MyTable].[MyDate] <= #04/22/2015# "
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 & "# "
ASKER