Answers for "calculate difference between two dates in apex salesforce"

0

calculate difference between two dates in apex salesforce

 
DateTime startDate = DateTime.newInstance(2020,1,1,3,0,0);
DateTime endDate = DateTime.newInstance(2020,1,3,6,0,0);
 
Decimal minutes = Integer.valueOf((endDate.getTime() - startDate.getTime())/(1000*60));
System.debug('Minutes : ' + minutes);
 
Decimal hours = Integer.valueOf((endDate.getTime() - startDate.getTime())/(1000*60*60));
System.debug('Hours : ' + hours);
 
Decimal days = Integer.valueOf((endDate.getTime() - startDate.getTime())/(1000*60*60*24));
System.debug('Days : ' + days);
Posted by: Guest on July-13-2021

Code answers related to "calculate difference between two dates in apex salesforce"

Browse Popular Code Answers by Language