Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
cldave

Automatically substract calendar months from a date

Hi,

I would need to be able to calculate via formula the previous 12 months from a date.

So example date is 4/1/2015

I would need 12 formula fields each being one of the 12 previous months. So formula would return those values using example above

1. 3/1/2015
2. 2/1/2015
3. 1/1/2015
4. 12/1/2014
5. 11/1/2014
......

Previous month is simple, but i'm hitting difficulties when previous month is also in previous year (month before january 2015)

If maybe someone could help be built a Generic formula that could accomplish that i would appreciate

P.S my date field will always be 1st of the month, so formula technicall does not need any special calcualtion for the "day"

Karanraj
Try the below formula which will give correcnt pervious month for any date value. As you requested your date is always 1
`DATE(IF(MONTH(SLAExpirationDate__c)==1,YEAR(SLAExpirationDate__c)-1,YEAR(SLAExpirationDate__c)),IF(MONTH(SLAExpirationDate__c)==1,12,MONTH(SLAExpirationDate__c)-1),1 )`
Thanks,
Karanraj
cldave
Hi Karanraj,