function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Need help finding LEAP YEARS in date ranges for contract expiration date to be correct via apex???

I have a system setup to allow contracts to create renewal contracts automatically.  The problem is that if the range contains a leap year my expiration date is off.

Ideally what I need is if we have a date range that co-terms a new contract with an existing one where the total term is 3 years six months and 5 days, and there is a leap year in the range how do I examine each year and determine if a leap year is in the range?

I will give kudos to anyone that can help me out or direct me to a resource that has a solution to this issue.
Well, just use Date.isLeapYear() to check all the years in your range.  Your term is a fixed number so it's easy to know what years you need to check.