I’m trying to set up a query that automatically tracks due dates for 30 day, QR 1, QR 2, QR 3, and QR 4 reports based on the anniversary date. The anniversary date is calculated from the mm/dd of the effective date and the current “yyyy”.
So far, I used the code below is as follows:
Code to calculate Anniversary Date and to update to current year:
IIf(DateDiff("yyyy",[Effective_Date],Date())>1,Format([Effective_Date],"mm/dd") & "/" & Format(Date(),"yyyy"),[Effective_Date])
Code to calculate due dates for reports:
[30 Day]: IIf(DateDiff("d",[Effective_Date],Date())>365, "N/A",DateAdd("d",30.4375,[Anniversary_Date]))
[QR 1]: DateAdd("d",91.3125,[Anniversary_Date])
[QR 2]: DateAdd("d",182.625,[ Anniversary_Date])
[QR 3]: DateAdd("d",273.9375,[ Anniversary_Date])
[QR 4]: DateAdd("d",365.25,[ Anniversary_Date])
Problem with this code: I get inaccurate results if I want to enter an effective date more than 1 year prior to Date(). I.e., if I entered 10/12/2002, my anniversary date becomes 10/12/05 and my first QR 1 isn’t due until 1/12/2006 when it should be 01/12/2005. Otherwise, formula works fine. How can I modify the formula that calculates the anniversary date to fix this problem? Perhaps I could write a formula to do away with anniversary date altogether and base reports on effective date.
Your suggestions would be greatly appreciated as I'm sure this wheel has already been invented (lol).
P.S.- I realize these functions will only give approximate due dates due to leap years but this is sufficient for the purposes I wish to use it for.
So far, I used the code below is as follows:
Code to calculate Anniversary Date and to update to current year:
IIf(DateDiff("yyyy",[Effective_Date],Date())>1,Format([Effective_Date],"mm/dd") & "/" & Format(Date(),"yyyy"),[Effective_Date])
Code to calculate due dates for reports:
[30 Day]: IIf(DateDiff("d",[Effective_Date],Date())>365, "N/A",DateAdd("d",30.4375,[Anniversary_Date]))
[QR 1]: DateAdd("d",91.3125,[Anniversary_Date])
[QR 2]: DateAdd("d",182.625,[ Anniversary_Date])
[QR 3]: DateAdd("d",273.9375,[ Anniversary_Date])
[QR 4]: DateAdd("d",365.25,[ Anniversary_Date])
Problem with this code: I get inaccurate results if I want to enter an effective date more than 1 year prior to Date(). I.e., if I entered 10/12/2002, my anniversary date becomes 10/12/05 and my first QR 1 isn’t due until 1/12/2006 when it should be 01/12/2005. Otherwise, formula works fine. How can I modify the formula that calculates the anniversary date to fix this problem? Perhaps I could write a formula to do away with anniversary date altogether and base reports on effective date.
Your suggestions would be greatly appreciated as I'm sure this wheel has already been invented (lol).
P.S.- I realize these functions will only give approximate due dates due to leap years but this is sufficient for the purposes I wish to use it for.