I have used this to calculate hours , but minutes part is not getting covered.
long businessMillisecondsDiff = BusinessHours.diff(bh.Id,cs.CreatedDate,system.now()); decimal businessHoursDiff = businessMillisecondsDiff / (1000.0*60.0*60.0);
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.Sign up to join this community
It does give you both, you just get minutes as a fraction of hours. If you want minutes only, you can just divide by 60:
Decimal businessMinutesDiff = calculatedDiff / (1000*60);
Or, if you want whole hours and the number of remainder minutes:
Decimal businessMinutesDiff = calculatedDiff / (1000*60); Decimal hours = businessHours.divide(60).round(RoundingMode.DOWN); Decimal minutes = businessMinutesDiff - 60 * hours;