+ Start a Discussion

Date Formula Field that calculates an end date

I have 2 date fields Period_Start_Date__c and Period_End_Date__c. Period_End_Date__c should be 364 days after the Period_Start_Date__c. This works fine for normal years but I have noticed that for a leap year (2020) it does not take the extra day into consideration.
Can somebody help me with a solution to this?
srlawr uksrlawr uk

I don't suppose you would mind posting the formula so we could have a look at how you are doing the + 364 days?

And perhaps a couple of examples (maybe screenshots, or just typed up pre and post conditions) ?

It's not a known issue with Salesforce dates to have problems with leap years as far as I know. If you have a glance at the "Adding Days, Months, and Years to a Date" section of this page


You'll see its the kind of thing that has been "thought about" in the past!! :D
Hi srlawr,

Ye I came across a lot of questions around this while trying to find a solution. I finally think I cracked it with the below formula

ServiceDate + (DATE(Year(ServiceDate) + FLOOR((MONTH(ServiceDate) + 9)/ 12) + 1, 1, 1) - DATE(Year(ServiceDate) + FLOOR((MONTH(ServiceDate) + 9)/12), 1, 1) - 1)