Skip to content

Instantly share code, notes, and snippets.

@lkatney
Created November 17, 2014 07:35
Show Gist options
  • Save lkatney/885837a48c5773f3beac to your computer and use it in GitHub Desktop.
Save lkatney/885837a48c5773f3beac to your computer and use it in GitHub Desktop.
Formula to calculate n months from date and give actual date - Salesforce
DATE(YEAR(DATEVALUE(Custom_date_field__c)),MONTH(DATEVALUE(Custom_date_field__c)),DAY(DATEVALUE(Custom_date_field__c))) - VALUE(TEXT(DATE(YEAR(DATEVALUE(Custom_date_field__c)),MONTH(DATEVALUE(Custom_date_field__c)),1) - DATE(IF(MONTH(DATEVALUE(Custom_date_field__c))+ 3 <= 12 ,YEAR(DATEVALUE(Custom_date_field__c)) , YEAR(DATEVALUE(Custom_date_field__c))+ 1), IF(MONTH(DATEVALUE(Custom_date_field__c))+ 3 <= 12 , MONTH(DATEVALUE(Custom_date_field__c))+ 3,MONTH(DATEVALUE(Custom_date_field__c))+ 3 - 12),1)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment