3
Answers

how to calculate time from time and end time in hour

Hello Sir,
   I have two dropdown list box.
dropdownlist1 is for start time and dropdown list 2 is for end time.
Exa...
  Suppose Dropdown list1 select 8:00 AM and dropdown list2 8:30 AM
I want to calculate time in hour and store in control also store in database
 
This is for timesheet.
Help me.. 
Answers (3)
1
Jithil John
NA 1k 59.5k 9y
DateTime t1 = Convert.ToDateTime(textBox1.Text); 
DateTime t2 = Convert.ToDateTime(textBox2.Text);
TimeSpan ts = t1.Subtract(t2);
1
Jithil John
NA 1k 59.5k 9y
 TimeSpan duration = new TimeSpan(endtime.Ticks - startTime.Ticks);
0
Jithil John
NA 1k 59.5k 9y
string startTime = "7:00 AM"; 
string endTime = "2:00 PM";
TimeSpan duration = DateTime.Parse(endTime).Subtract(DateTime.Parse(startTime));