How do I account for leap years when adding 1 or 3 years to a date?

I have a database of clients on programs with expiry dates based on qualification date. Some programs expire in 3 years and some expire in 1 year. I was adding either 364 or 1094 to the date. Leap year seems to be throwing a wrench into this. Any ideas?

Here is my code. I have a few other conditions in the calculation but the one I'm struggling with is adding 1 or 3 years to the qualification date and not losing a day because of the leap year.

=IF(AND([Meet 17025 2017]@row = "no", [APPLICABLECSA PROGRAM IDENTIFIER]@row = "WMTC", [QUALIFICATION DATE]@row < DATE(2019, 11, 30)), [QUALIFICATION DATE]@row + 364, IF(AND([Meet 17025 2017]@row = "no", [APPLICABLECSA PROGRAM IDENTIFIER]@row = "TMPC", [QUALIFICATION DATE]@row < DATE(2019, 11, 30)), [QUALIFICATION DATE]@row + 364, IF(AND([Meet 17025 2017]@row = "no", [APPLICABLECSA PROGRAM IDENTIFIER]@row = "FC", [QUALIFICATION DATE]@row < DATE(2019, 11, 30)), [QUALIFICATION DATE]@row + 364, IF(AND([Meet 17025 2017]@row = "no", [APPLICABLECSA PROGRAM IDENTIFIER]@row = "CTF Stage 1", [QUALIFICATION DATE]@row < DATE(2019, 11, 30)), [QUALIFICATION DATE]@row + 364, IF(AND([Meet 17025 2017]@row = "no", [APPLICABLECSA PROGRAM IDENTIFIER]@row = "CTF Stage 2", [QUALIFICATION DATE]@row < DATE(2019, 11, 30)), [QUALIFICATION DATE]@row + 364, IF(AND([Meet 17025 2017]@row = "no", [QUALIFICATION DATE]@row > DATE(2017, 11, 30)), DATE(2020, 11, 30), IF(AND([Meet 17025 2017]@row = "no", [QUALIFICATION DATE]@row > DATE(2019, 11, 30)), DATE(2020, 11, 30), IF([Registered CTF TYPE “LSV”]@row = 1, [QUALIFICATION DATE]@row + 364, IF([APPLICABLECSA PROGRAM IDENTIFIER]@row = "WMTC", [QUALIFICATION DATE]@row + 364, IF([APPLICABLECSA PROGRAM IDENTIFIER]@row = "TMPC", [QUALIFICATION DATE]@row + 364, IF([APPLICABLECSA PROGRAM IDENTIFIER]@row = "CTF Stage 1", [QUALIFICATION DATE]@row + 364, IF([APPLICABLECSA PROGRAM IDENTIFIER]@row = "CTF Stage 2", [QUALIFICATION DATE]@row + 364, IF([APPLICABLECSA PROGRAM IDENTIFIER]@row = "APT", [QUALIFICATION DATE]@row + 364, IF([APPLICABLECSA PROGRAM IDENTIFIER]@row = "FC", [QUALIFICATION DATE]@row + 364, [QUALIFICATION DATE]@row + 1094))))))))))))))

Tags:

Best Answer

Answers

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!