I have the following code to add weekly timesheet (time) values to produce the weeks total
But I need to convert the outcome (lblTotal) to decimal and place in txtTotal
TimeSpan duration = TimeSpan.Parse(lbl1.Text).Add(TimeSpan.Parse(lbl2.Text).Add(TimeSpan.Parse(lbl3.Text).Add(TimeSpan.Parse(lbl4.Text).Add(TimeSpan.Parse(lbl5.Text).Add(TimeSpan.Parse(lbl6.Text))))));
But I need to convert the outcome (lblTotal) to decimal and place in txtTotal
TimeSpan duration = TimeSpan.Parse(lbl1.Text).Add(TimeSpan.Parse(lbl2.Text).Add(TimeSpan.Parse(lbl3.Text).Add(TimeSpan.Parse(lbl4.Text).Add(TimeSpan.Parse(lbl5.Text).Add(TimeSpan.Parse(lbl6.Text))))));
lblTotal.Text = "" + (duration);
I have tried the following:
I have tried the following:
txtTotal.Text = Convert.ToDecimal(duration).ToString("#.00");
but no matter how I change it around keep getting the
System.TimeSpan' to type 'System.IConvertible error
Any help would be great
but no matter how I change it around keep getting the
System.TimeSpan' to type 'System.IConvertible error
Any help would be great
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

VulpesRank #55 · 29.2K reputationPosted Apr 23, 2014, 1:11 PM EDT
txtTotal.Text = duration.TotalHours.ToString("F2");
Callie4 reputationPosted Apr 23, 2014, 1:34 PM EDT