[SalesForce] How to make a date formula which calculates current month + 3 Full months in Salesforce

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

Best Answer

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
)