# Using rules engine to correctly account for leap years

• Question
• Updated 4 months ago
I currently have a rule built out that looks at a certain date field (we'll call it Date XYZ) and when the current date (rule date) is 365 days ahead of "Date XYZ", it triggers the setup action. Within the Setup Rule, the only way to determine if a certain date is exactly 1 year in the past is through the "Subtract N Days from Rule Date". This works fine with N = 365 except for leap years where N needs to equal 366. Doing a simple OR statement won't give me the correct results for when the year is a non-leap year. Anyone have any experience working with year anniversary based setup actions accounting for leap years?
• 356 Points
• hopeful

Posted 4 months ago

Dan Ahrens, Official Rep

• 25,920 Points
Hi Shane,

It sounds like you need to look for the exact calendar day of the month, right? So on June 26, 2019 you'd trigger a rule action for a customer who signed on June 26, 2018. Is this right?

What's the action you're triggering and what's the impact if it's one day off?

A simplistic way to solve for this would be to change the N=365 to N=366 on February 29 and then change it back on Feb 28 the following year. ;-)
• 356 Points
You are correct.

It's quite important that these dates are as accurate as possible because we are looking at contract expiration / renewal dates.

It is true that we could just change it to N=366 on February 29 of 2020 up until February 28 of 2021.