function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
pradeep naredlapradeep naredla 

How to add months to a date field Using Formula

I have a date field and its a fromula field i need a formula to add 11months to one of the other date fields. formula has to be like it has to add 11months and need to display lastday of the month in my formula tried all the cases 

DATE((YEAR(MyCustome_Field__c)+FLOOR(((MONTH(MyCustome_Field__c)+ 11)-1)/12)),MOD((MONTH(MyCustome_Field__c)+ 11)-1,12)+1,DAY( 
(DATE(YEAR(MyCustome_Field__c),MONTH(MyCustome_Field__c),1)-1)))

I have written this formula but it is not working fine for march i dont know why it is acting weird if i give any date except date in march it is working fine but if i give date in march saylike 12-03-16 it has to show 28-02-17 but it is showing #Error for other months it is working fine help me with this.
Ekaterina GetaEkaterina Geta

Hello Pradeep,

Not sure if it's still relevant, but in case it is my answer is below.

You didn't take into account the length of February which is 28 or 29 days. 

You should use this formula for it to work correctly. 

IF(
  MOD( MONTH( date ) + 2, 12 ) = 2,
  IF(
    DAY( date ) > 28,
    DATE( YEAR( date ) + FLOOR( ( MONTH( date ) + 2 ) / 12 ), 3, 1 ),
    DATE( YEAR( date ) + FLOOR( ( MONTH( date ) + 2 ) / 12 ), 2, DAY( date ) )
  ),
  IF(
    OR(
      MOD( MONTH( date ) + 2, 12 ) = 4,
      MOD( MONTH( date ) + 2, 12 ) = 6,
      MOD( MONTH( date ) + 2, 12 ) = 9,
      MOD( MONTH( date ) + 2, 12 ) = 11
    ),
    IF(
      DAY( date ) > 30,
      DATE( YEAR( date ) + FLOOR( ( MONTH(  date  ) + 2 ) / 12 ),
       MOD( MONTH( date ) + 2, 12 ) + 1, 1 ),
      DATE( YEAR( date ) + FLOOR( ( MONTH( date ) + 2 ) / 12 ),
       MOD( MONTH( date ) + 2, 12), DAY( date ) )
    ),
    IF(
      MOD( MONTH( date ) + 2, 12 ) = 0,
      DATE( YEAR( date ) + FLOOR( ( MONTH( date ) + 2 ) / 12 ) - 1, 12, DAY( date ) ),
      DATE( YEAR( date ) + FLOOR( ( MONTH( date ) + 2 ) / 12 ),
       MOD( MONTH( date ) + 2, 12), DAY( date ) )
    )
  )
)

Best regards,

Ekaterina

Ekaterina GetaEkaterina Geta
You can also use the ADDMONTHS function.

For more details refer here - http://getawayposts.com/add-months-date-salesforce-formula-addmonths-function