0

I am using a Process builder to set value to the field expiry_date__c based on booking_date__c

Example 1:

If booking_date__c is 12th June 2017, the expiry_date__c must be calculated as current month + 3 full months from July. So expiry date must get populated to 30th September.

Example 2: If booking_date__c is 5th February 2017, expiry_date__c must be 31st May 2017

5
  • expiry_date__c is a formula field of just date field ? Commented Jun 12, 2017 at 6:06
  • 2
    Try with this logic. DATE(YEAR(StartDate),MONTH(StartDate)+3,1)-1
    – S B
    Commented Jun 12, 2017 at 6:48
  • Think it should be DATE(YEAR(StartDate),MONTH(StartDate)+4,1)-1. if you have 3 it goes to May but cheryl wants it to be end of the 3rd month.
    – RedDevil
    Commented Jun 12, 2017 at 7:04
  • @ShravanBoddula your formula is not working, when month is October or further months Commented Jun 12, 2017 at 7:12
  • @MuzammilBajaria - the 'expiry_date__c' is a date field
    – Cheryl
    Commented Jun 12, 2017 at 7:27

1 Answer 1

5

Formula should consider two cases, when month <= 8 and month > 8. The following formula works for any date.

IF(
    MONTH(Date__c) <= 8,
    DATE(
        YEAR(Date__c),
        MONTH(Date__c)+4,
        1)
    -1
    ,
    DATE(
        YEAR(Date__c)+1,
        MONTH(Date__c)+4-12,
        1)
    -1
)
1
  • That works perfect @Alexander, thank you. So I see the catch was to split them in two different cases.
    – Cheryl
    Commented Jun 12, 2017 at 10:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .