var d1 = Convert.ToDateTime(list[0].BeginTime); var d2 = Convert.ToDateTime(list[0].EndTime); var difference = Time2TimeStamp(d2) - Time2TimeStamp(d1); var housr = difference / 3600.0; if (housr - (int)housr > 0) { housr = (int)housr + 1; }