subtract two datetime fields return wrong total of hours value

.net, c#, c#-4.0, datetime

Solution

you just do

double res = (y - x).TotalHours;

because c# already knows so subtract to `dateTime` types and return the result as a `timeSpan`

the result is 0.0775 because the difference is 279 seconds. divide by 60 (to minutes) is 4.65 minutes, divide by 60 again for hours is 0.0775 as you get.

Problem

I try to write code that subtract two datetime fields and return the result to TimeSpan object and return the Total Hours value. ``` DateTime x = new DateTime(2013, 7, 18, 12, 57, 40); DateTime y = new DateTime(2013, 7, 18, 13, 2, 19); double m = y.Subtract(x).TotalHours; ``` I expect the value of `m` is 0.073166667 but the actual result is 0.0775 why? Edit I'm sorry I use the google calculator in wrong way BTW thank you @Liran Elisha and @FSou1

Original source