0

I have a date field (datefield__c) that i want to subtract 11 months. How can I do this using formula in Process builder? I tried to use the below code:

DATE(YEAR(datefield__c), MONTH(datefield__c) - 11, DAY(datefield__c))

But when the month is Feb to Dec, the year doesn't subtract and also when subtracting dates from January 31, the value doesn't display because there's no February 31. Anyone knows how to fix this one?

4
  • You can find an example of adding 2 months to a date as formula here. You just have to adapt it to your needs. Jul 13 '17 at 7:46
  • @MartinLezer When testing out the formula there, when the date is August 31, 2017, the result is October 1, 2017 base on the formula. I think there's something wrong with the formula and can't figure it out.
    – JMRAF69
    Jul 13 '17 at 8:37
  • This is because the sample formula adds 2 months to the date. You have to adapt it to your needs. Jul 13 '17 at 8:51
  • @MartinLezer Yes I know that it adds 2 month to the date but when I tested it out, the result for August 31, 2017 becomes October 1 however the result should be September 30.
    – JMRAF69
    Jul 13 '17 at 8:57
0

the best way to do it will be using Apex as an invocable method from Process Builder.

Salesforce provided +2 months formula not for subtraction as with subtraction for date like 01-01-2017 will break the formula and throw an error 'EITHER DATE OR MONTH IS INVALID"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.