I want to show the last 3 months of data based on a date field. MajP gave me this code which I have in a module and I callupon. However, I have just noticed that it brings back the last 3 months of data regardless of the year. Can I chnage it to ensure it brings back the last 3 months only? I expect this is probably quite simple but I am very rusty...thanks in advance for any help.
Public Function LastDateM(dtmDate)
'Return the Last date of provided month
'
LastDateM = DateSerial(Year(dtmDate), Month(dtmDate) + 1, 0)
End Function
Public Function firstDayM(dtmDate)
'Return the First day of provided month
'
firstDayM = DateSerial(Year(dtmDate), Month(dtmDate), 1)
End Function
Public Function EndDateRange()
LastDateM (Date)
End Function
Public Function startDateRange(MonthsPrevious As Integer)
'
startDateRange = firstDayM(LastDateM(Date) - (MonthsPrevious) * 31)
End Function
Public Function LastDateM(dtmDate)
'Return the Last date of provided month
'
LastDateM = DateSerial(Year(dtmDate), Month(dtmDate) + 1, 0)
End Function
Public Function firstDayM(dtmDate)
'Return the First day of provided month
'
firstDayM = DateSerial(Year(dtmDate), Month(dtmDate), 1)
End Function
Public Function EndDateRange()
LastDateM (Date)
End Function
Public Function startDateRange(MonthsPrevious As Integer)
'
startDateRange = firstDayM(LastDateM(Date) - (MonthsPrevious) * 31)
End Function