You need to sign in to do that
Don't have an account?
chiranjib rout
how do I add 6 months to a date field in a formula?
Hii friends, 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?? For the above question i have wrote the below formula=
DATE( IF(MONTH(DOJ__c )>6, YEAR(DOJ__c ) + 1 , YEAR(DOJ__c)) ,
IF( MONTH(DOJ__c)+6 > 12, (MONTH(DOJ__c)+6)-12, MONTH(DOJ__c)+6) ,
IF(OR(DAY(DOJ__c) = 31,DAY(DOJ__c) = 29,DAY(DOJ__c) = 28),
CASE(IF( MONTH(DOJ__c)+6 > 12, (MONTH(DOJ__c)+6)-12, MONTH(DOJ__c)+6), 1, 31,
2, IF(OR(MOD(IF(MONTH(DOJ__c )>6, YEAR(DOJ__c ) + 1 , YEAR(DOJ__c )),400)=0,AND(MOD(IF(MONTH(DOJ__c )>6, YEAR(DOJ__c ) + 1 , YEAR(DOJ__c )),4)=0,MOD(IF(MONTH(DOJ__c )>6, YEAR(DOJ__c ) + 1 , YEAR(DOJ__c )),100)<>0)),
29, 28),
3,31,4,30,5,31,6,31,7,30,8,31,9,30,10,31,11,30,12,31,0)
, DAY(DOJ__c)) )
The Formula code is working but when i am trying the date like 28,29,31 December its showing error plz suggest
DATE( IF(MONTH(DOJ__c )>6, YEAR(DOJ__c ) + 1 , YEAR(DOJ__c)) ,
IF( MONTH(DOJ__c)+6 > 12, (MONTH(DOJ__c)+6)-12, MONTH(DOJ__c)+6) ,
IF(OR(DAY(DOJ__c) = 31,DAY(DOJ__c) = 29,DAY(DOJ__c) = 28),
CASE(IF( MONTH(DOJ__c)+6 > 12, (MONTH(DOJ__c)+6)-12, MONTH(DOJ__c)+6), 1, 31,
2, IF(OR(MOD(IF(MONTH(DOJ__c )>6, YEAR(DOJ__c ) + 1 , YEAR(DOJ__c )),400)=0,AND(MOD(IF(MONTH(DOJ__c )>6, YEAR(DOJ__c ) + 1 , YEAR(DOJ__c )),4)=0,MOD(IF(MONTH(DOJ__c )>6, YEAR(DOJ__c ) + 1 , YEAR(DOJ__c )),100)<>0)),
29, 28),
3,31,4,30,5,31,6,31,7,30,8,31,9,30,10,31,11,30,12,31,0)
, DAY(DOJ__c)) )
The Formula code is working but when i am trying the date like 28,29,31 December its showing error plz suggest
Please check this formula:
Thanks,
Dhanya
Salesforce addresses this scenario in their examples:
https://help.salesforce.com/HTViewHelpDoc?id=formula_examples_dates.htm#adding-day-to-date
I have modified the formula. please check below:
Also I checked and it works fine. Let me know if you face any issues.
Thanks and Regards,
Sai Krishna Tavva.
Hopefully this should work. Cheers Mate!!
Because I think I have leap-year-proof formula for adding months (doesn't work with negative months count) but compile size is pretty big - 2,257 characters.