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 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Apr 23, 2014, 5:11 PM
txtTotal.Text = duration.TotalHours.ToString("F2");
CalliePosted Apr 23, 2014, 5:34 PM