2 added 585 characters in body
source | link

You can utilize Datetime's getTime() method and compare the two values.

Datetime firstTime = Datetime.newInstance(2016, 9, 22, 12, 30, 0);
Datetime secondTime = Datetime.newInstance(2016, 9, 23, 14, 00, 0);

Decimal millisecondsBetween = secondTime.getTime() - firstTime.getTime(); //NB: ths is important as to convert type
Decimal timeBetween = millisecondsBetween / 86400000;  //1000 * 60 * 60 * 24
System.debug(timeBetween);

Above is the sample code. I got the value 1.0625 which I think is correct. Please Note you need to convert the type into Decimal before divided by 86400000. Otherwise, the result would be 1.

You can utilize Datetime's getTime() method and compare the two values

You can utilize Datetime's getTime() method and compare the two values.

Datetime firstTime = Datetime.newInstance(2016, 9, 22, 12, 30, 0);
Datetime secondTime = Datetime.newInstance(2016, 9, 23, 14, 00, 0);

Decimal millisecondsBetween = secondTime.getTime() - firstTime.getTime(); //NB: ths is important as to convert type
Decimal timeBetween = millisecondsBetween / 86400000;  //1000 * 60 * 60 * 24
System.debug(timeBetween);

Above is the sample code. I got the value 1.0625 which I think is correct. Please Note you need to convert the type into Decimal before divided by 86400000. Otherwise, the result would be 1.

1
source | link

You can utilize Datetime's getTime() method and compare the two values