Hi every one!

I have an acces table viewed in datagridview and trying to add the values of column 3 and 4 (date time data types). my code is as below.

string StartTime = dataGridView1.Rows[i].Cells[3].Value.ToString();
string StartTime = dataGridView1.Rows[i].Cells[3].Value.ToString();
                 string Total = dataGridView1.Rows[i].Cells.Value.ToString();
                 MessageBox.Show(StartTime);
                 TimeSpan spantotal = TimeSpan.Parse(Total); //convert f into timespan and store in a
                 TimeSpan spanStartTime = TimeSpan.Parse(StartTime);
                 TimeSpan SpanEndTime = (spantotal.Add(spanStartTime));// sum of timespan a and b store in c
                 TimeEnd = new DateTime(SpanEndTime.Ticks);
                 string strTimeEnd = TimeEnd.ToString("hh:mm tt");
                 dataGridView1.Rows[i].Cells[4].Value = strTimeEnd;   //assign c to to.value]

What exactly is your problem?
Do you know DateTime has an Add method and that the + operator can be used to perform additions of DateTime and TimeSpan?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.