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
mac_046mac_046 

Calculating number of days between two dates.....

 

Hello Everyone,

 

I have a picklist field with "submitted" and "approved" values. I need to calculate the number of days between the two dates i:e (the date that record was submitted and date that record was approved). Can anyone tell mehow to achieve this requirement.

 

Thanks in advance  

kamlesh_chauhankamlesh_chauhan

Hi Mac,

 

Add new formula field and use below foluma to calculate the same.

 

 

DateApproved - DateSubmitted

 

 

Regards,

Kamlesh

 

miguel.guerreiromiguel.guerreiro

Hello,

 

I guess you have two fields to capture those dates. Then simply create a formula field and calculate the difference:

 

 

To__c - From__c

 

 

Cory CowgillCory Cowgill

FYI - In additional to workflows the Apex Date Object has fields for performing this functionality.

 

The Date object has methods to calculate the number of days between two dates.

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_date.htm?SearchType=Stem&Highlight=Date|Dates|dates|date|DATE

 

daysBetweenDate compDateIntegerReturns the number of days between the Date that called the method and the compDate. If the Date that calls the method occurs after the compDate, the return value is negative. For example:
 date startDate = 
date.newInstance(2008, 1, 1);
date dueDate =
date.newInstance(2008, 1, 30);
integer numberDaysDue =
startDate.daysBetween(dueDate);