int s = 0;
//Start time
int start_year =2010;
int start_month = 10;
int start_day = 2;
int start_hour = 0;
int start_min = 0;
//End time
int end_year = 2010;
int end_month = 10;
int end_day = 3;
int end_hour = 0;
int end_min = 0;
DateTime startTime = new DateTime(start_year,start_month,start_day, start_hour, start_min,s); // 05:40 Hour
DateTime endTime = new DateTime(end_year, end_month, end_day, end_hour, end_min, s); // 17:45 Hour
TimeSpan diff = endTime - startTime;
int hourDiff = diff.Hours; // 12 Hours
int minDiff = diff.Minutes; // 15 Mins
double totDiffHours = (double)hourDiff + (double)minDiff /60; // 12.25 Hours
// double hhh = (DateTime) diff / 24;
Label1.Text = Convert.ToString(diff);
How to convert days into hours?
Thanks
View Complete Post