I am getting the difference in time between two date/time fields. I need to show the time in hours:minutes in another field.
Long timeOpen = BusinessHours.diff(bh.Id, ar.Date_Time_Assigned__c, ar.Completed_Canceled_Date_Time__c);
Long seconds = timeOpen / 1000;
Long minutes = seconds / 60;
Long hours = minutes / 60;
ar.Time_Open__c = hours;
Right now, I'm only getting the hours, but I need to include the minutes too.
minutes = seconds * 60
andhours = minutes * 60
. Did you perhaps mean to putminutes = timeOpen / 60
or were you looking to get theintegerValue
oftimeOpen / 60
and then use the remainder to do your calculations with forminutes
, and similarly forseconds
, etc?mod
. See Math Methods in the Apex Code Developer's Guide for more.