Query over past six CALENDAR months

Courtman

Paranoid Android
Local time
Today, 20:02
Joined
Dec 8, 2001
Messages
34
Hiya all

I'm trying to write a query which looks back over the past six calendar months - i.e. from today back to 01-Mar-2008. Can anyone recommend the easiest way to do this in a query please?

Thanks!
 
Assuming your table date is date format
Code:
strSql = Select * From yourtable Where yourdbdate > #' & Dateadd("m",-6,Date) & "#"
If you want the first day of the month, then use
Code:
strSql = Select * From yourtable Where yourdbdate > #' & DateSerial(Year(Date()), Month(Date())-6,1)
 & "#"
 
Brilliant, my SQL query now looks like this:

Code:
SELECT Sum([Log Entries].[Instr Apps]) AS [SumOfInstr Apps]
FROM [Log Entries]
WHERE [Log Entries].[Date] > DateSerial(Year(Date()), Month(Date())-6,1);

and works perfectly. Thank you!
 

Users who are viewing this thread

Back
Top Bottom