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

  • expiry_date__c is a formula field of just date field ? – Muzammil Bajaria Jun 12 '17 at 6:06
  • 2
    Try with this logic. DATE(YEAR(StartDate),MONTH(StartDate)+3,1)-1 – Shravan Boddula Jun 12 '17 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 Jun 12 '17 at 7:04
  • @ShravanBoddula your formula is not working, when month is October or further months – Oleksandr Berehovskyi Jun 12 '17 at 7:12
  • @MuzammilBajaria - the 'expiry_date__c' is a date field – Cheryl Jun 12 '17 at 7:27
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
)
| improve this answer | |
  • That works perfect @Alexander, thank you. So I see the catch was to split them in two different cases. – Cheryl Jun 12 '17 at 10:35

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.