 ShowAll Questionssorted byDate Posted pradeep 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 Geta

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 Geta
You can also use the ADDMONTHS function.