Greetings, I want to build a query that runs daily to select some past records. I would like to have it work as follows:
1 - On any day other than the first day of the current month, I need records from the first day of the current month to previous day of the current day ie - on the 17th, I need the 1st thru the 16th (Current month aggregate)
2 - On the first on the month, I need records from the 1st day of the previous month to the first day of the current month (Previous month total)
Here is what I have tried so far in the criteria field of my date\time column:
IIf(DatePart('d',[Response_Date])<>1,((Between DateSerial(Year(Date()),Month(Date()),Day(Date())-1) And DateSerial(Year(Date()),Month(Date()),Day(Date())) ,(Between DateSerial(Year(Date()),Month(Date())-1,1) And DateSerial(Year(Date()),Month(Date()),1)
I have also been toying with another type of statement (below) but am not sure how to get the statement to evaluate the IF function and select the proper date range accordingly
In (SELECT [Response_Date] FROM [dbo_Response_Master_Incident] WHERE [Response_Date] BETWEEN #01/01/10# AND #07/01/10#)
I am on the right track here or is there another easy way to accomplish this goal?? Thanks for any help.