How to add months to date field in salesforce using formula expression builder

If you want to add say 6 months to the date fields in salesforce,its not straightforward. Please see this example as to how to achieve it.

DATE( 
YEAR(start_date__c) + FLOOR( ( MONTH (start_date__c) + 6 - 1 ) / 12 ), 
MOD( MONTH (start_date__c) + 6- 1 + 
IF( DAY (start_date__c) > CASE( MOD( MONTH(start_date__c) +6- 1, 12 ) + 1, 
2, 28, 
4, 30, 
6, 30, 
9, 30, 
11, 30, 
31 ), 1, 0 ), 12 ) + 1, 
IF( DAY(start_date__c ) > CASE( MOD( MONTH(start_date__c ) +6 - 1, 12 ) + 1, 
2, 28, 
4, 30, 
6, 30, 
9, 30, 
11, 30, 
31 ), 
1, DAY(start_date__c ) 
)


Comments

Popular posts from this blog

Learn Solidity Programming to build BlockChain contracts for ethereum

Learn salesforce admin and salesforce developer concepts ,Learn to build apex class,triggers,rest api,soap api,asynchronous class programming