Using Access 2007
A members’ database. On a form the user selects the month for which a report is desired. This calls for a report of members’ wedding anniversaries occurring in the month selected from the list on the form.
SELECT MemberID, LastName, PreferredName, WeddingAnniversary, "Wedding Anniversary",Status,DateDiff("yyyy",[WeddingAnniversary],Date())+Int(Month(Date())<Month([WeddingAnniversary])) AS FixWeddingAnniversaryYears,Month(WeddingAnniversary) As Month,Day([WeddingAnniversary]) as Day,Switch([Month]=1,"January",[Month]=2,"February",[Month]=3,"March",[Month]=4,"April",[Month]=5,"May",[Month]=6,"June",[Month]=7,"July",[Month]=8,"August",[Month]=9,"September",[Month]=10,"October",[Month]=11,"November",[Month]=12,"December") AS Sort FROM tblMembers WHERE (tblMembers.Status="Active" Or tblMembers.Status="Senior") And ([WeddingAnniversary] Is Not Null)
If the user selects March, and we're in March, the results are correct.
If, however, the user selects March from sometime in February, the results in anniversary years are 1 less than they should be.
e.g. Member Brown has actually been married 30 years as of March 15. If we are in March, 30 years is what shows when the March report is selected.
However, if the user wants to run the report in late February, Member Brown shows as being married 29 years in March.
Not exactly sure how to fix this. I suspect it has to do with the Date() function.
Suggestions would be appreciated.
Tom