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
Manoj DegaManoj Dega 

Caluculate New Date Using Date Formula Field

Hi All,

Can you Please tell me how to achive these
 
New_Date__c //Custom Field
Activity_Date__c // Another Custom Field

 New_Date__c = (Activity date + 1 Year) - ( 3 Months + 7 Days)

Thanks in Advance
Leslie  KismartoniLeslie Kismartoni
Check the doc here: https://help.salesforce.com/apex/HTViewHelpDoc?id=formula_using_date_datetime.htm&language=en_US

You can create a formula field that will display a new date. Something like:
 
Date(Year(Activity_Date__c), Month(Activity_Date__c), Days(Activity_Date__c) )

You can do math on the individual values 
Year(Activity_Date__c)  +  1, 3+Month(Activity_Date__c), etc...



 
Leslie  KismartoniLeslie Kismartoni
if you need to set a specific field, you'd probably have to look at workflows or APEX triggers... 
ManojjenaManojjena
Hi Manoj ,

I don't think it is possible to achieve nither  with formula nor with workflow .You can achieve this with the help of trigger .
So basically you can simplyfy your logic ,like you are adding 1 year means always 12 month and substracting 3month means ultimatly  you need to add 9 month and seven days .

So you try with trigger and use below code in before insert and before update .

New_Date__c=Activity_Date__c.addMonth(9).addDays(7);

Thnaks 
Manoj