Using rules engine to correctly account for leap years

  • 1
  • Question
  • Updated 4 months ago
  • Answered
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?
Photo of Shane McCoy

Shane McCoy

  • 356 Points 250 badge 2x thumb
  • hopeful

Posted 4 months ago

  • 1
Photo of Dan Ahrens

Dan Ahrens, Official Rep

  • 25,920 Points 20k badge 2x thumb
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. ;-)
Photo of Shane McCoy

Shane McCoy

  • 356 Points 250 badge 2x thumb
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.