Hi,
How to Convert TimeSpan to Decimal format, my code looks like this
TimeSpan ts = new TimeSpan();
ts = datetimepickerouttime.Value.TimeOfDay - datetimepickerintime.Value.TimeOfDay;
ts = ts.Subtract(TimeSpan.FromMinutes(30));
TextBox1.Text = Convert.ToDecimal(Convert.ToDecimal(ts.Hours) + (Convert.ToDecimal(ts.Minutes))).ToString("#.00");
Thanks in Advance,
Converting Timespan to Decimal
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

AlanRank #669 · 3.6K reputationPosted Aug 7, 2008, 12:04 AM EDT
If you mean that (for example) you want to convert 8 hours 30 minutes to 8.50 hours, then you can do it like this:
TextBox1.Text = Convert.ToDecimal(ts.TotalHours).ToString("#.00");