0

I have 2-time fields (Start time and End Time). I need to calculate the difference in minutes. I have tried with below code, but does not work.

 Double var = Math.Floor((Double.valueOf(mem.End__c.getTime()) - Double.valueOf(mem.Start__c.getTime())) / (1000.0*60.0*60.0));

The trigger is not getting saved, saying that getTime() method is not valid. I guess it work for Datetime field.

Please help!

1 Answer 1

0

Have a look at the Time class in apex here

You can use hour() to get the hour and convert it to minutes for both time fields and compute the difference.

You can also look at other functions minute() and second() as well in the link provided to get more accurate results.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .