I have been building a program where i need to calculate the difference between different dates....... its a network outage program i want to calculate down time between different dates e.g network was down on 08/06/2013 9:00 AM and was restored on 09/06/2013 10:00 PM.... the down time should be 34 hours......... i have been able to calculate the days but i want this in hour format so anyone please help me............. i m using datetimePicker to get the date and time at the same time.
i have been using the below mentioned code for that purpose
dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = " dd/MM/yyyy hh:mm tt ";
dateTimePicker2.Format = DateTimePickerFormat.Custom;
dateTimePicker2.CustomFormat = " dd/MM/yyyy hh:mm tt ";
ts1 = dt2.Subtract(dt1);
richTextBox1.Text = "The Hours Difference is:\t" + dt2.Subtract(dt1).Hours + "\n The Minute Difference is:\t" + dt2.Subtract(dt1).Minutes;