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
chiranjib routchiranjib rout 

how do I add 6 months to a date field in a formula??

hii everyone, how do I add 6 months to a date field in a formula? There are two  Date fields date of joining(DOJ_c) and  a formulafield  (Conformation_Date_c) ,if i put any date in date of joining (DOJ_c) field then in the conformation date =(date of joining + 6 month). kindly provide the formula for  conformation Date.
 
Best Answer chosen by chiranjib rout
mritzimritzi
Hi Chiranjib,
Use following formula for the formula field Confirmation_Date__c (return type Date) 
IF( MONTH(DOJ_c)>6, 
      DATE( YEAR(DOJ_c)+1 , MOD (MONTH(DOJ_c)+6,12) , DAY(DOJ_c) ) , 
      DATE( YEAR(DOJ_c) , MONTH(DOJ_c)+6 , DAY(DOJ_c) )
)

This formula works for every month from 1 to 12.

mark this as Best Answer, if this solves your problem.

All Answers

Dhanya NDhanya N
Hi Chiranjib,

Create formula field 'Conformation Date' of type Date and use below formula:
DATE( YEAR( DOJ__c ) , (MONTH( DOJ__c ))+6, DAY( DOJ__c ) )
Thanks,
Dhanya
 
mritzimritzi
Hi Chiranjib,
Use following formula for the formula field Confirmation_Date__c (return type Date) 
IF( MONTH(DOJ_c)>6, 
      DATE( YEAR(DOJ_c)+1 , MOD (MONTH(DOJ_c)+6,12) , DAY(DOJ_c) ) , 
      DATE( YEAR(DOJ_c) , MONTH(DOJ_c)+6 , DAY(DOJ_c) )
)

This formula works for every month from 1 to 12.

mark this as Best Answer, if this solves your problem.
This was selected as the best answer
chiranjib routchiranjib rout
hii mritzi teh code is running correctly but when ever i am trying date like 31/5/2016 it showing error so suggest
mritzimritzi
I see....
An easy way out of this is to simply add 180 days to DOJ__c in the formula editor. Confirmation_Date__c (return type Date) 
DOJ__c +180

Because, such problem would arise for all "31st" dates and also for the 29th feb(in case of leap year).
It would require too many cases and conditions, that would make the formula fairly complex.
And i don't think, its that important to put that much effort.

Because, even if you try to implement a complex formula, the confirmation date would be different from joining date (in case of31 st of month, 29 th feb), it has to be reduced by one day. There are too many edge cases to consider.
Yasmine GhezliYasmine Ghezli
Hello,
You can use the ADDMONTHS(Date,Num) formula that will take in concideration the 31 of each months and the 28 - 29 of febuary.
Here is where I found it : https://trailhead.salesforce.com/fr/content/learn/modules/advanced_formulas/date_formulas

All the best