Using Formula
The below formula return the number of days between two Fields. Create a formula field and select data type as Number and then put the below formula :-
TODAY() - DATEVALUE(dateField1)
OR
DATEVALUE(dateField1) - DATEVALUE(dateField2)
ex : 8/1/2021 - 7/8/2021
Output : 24
Using Apex Code
Date startDate = Date.today();
Date endDate = Date.today().addDays(10);
Integer noOfDays = startDate.daysBetween( endDate );
system.debug( 'Output is ' + noOfDays );
Output : 10
Comments