Hello. Im trying to add 2 times in C# windows form app. I have a function where I am retrieving a time field from database and adding it to another time which is in a texbox. I am able to retrieve the time field but when I am adding and saving, it is saving the date also for example 6:00:00 + 4:00:00, i get Apr 14 2011 10:00PM. I have tried several ways with same results. I just need to add the 2 times.
DateTime Staff_Total_Hours = Convert.ToDateTime(cmd.ExecuteScalar().ToString());
Staff_Total_Hours = Staff_Total_Hours + TimeSpan.Parse(txtTime.Text);
DateTime Staff_Total_Hours = DateTime.Parse(textBox1.Text);
Staff_Total_Hours = Staff_Total_Hours + TimeSpan.Parse(txtTime.Text);
TextBox1.Text = "0";
DateTime zero = Convert.ToDateTime(TextBox1.Text);
DateTime dt1 = Convert.ToDateTime(cmd.ExecuteScalar().ToString());
DateTime dt1 = Convert.ToDateTime(total);
DateTime dt2 = Convert.ToDateTime(txtTime.Text);
TimeSpan dt3 = dt2.Subtract(zero);
DateTime Staff_Total_Hours = dt1.Add(dt3);
None of them are giving the correct result. I will be veru grateful if anyone can help me!