Reputation: 403
TimeSpan totaldays = endtime.Subtract(starttime);
double tdays = Convert.ToDouble(totaldays);
I m getting here error as
Unable to cast object of type 'System.TimeSpan' to type 'System.IConvertible'.
how can I get timespan value as a double type
Upvotes: 2
Views: 2235
Reputation: 1618
being more simple
double d=(endtime-starttime).totaldays;
worked for me.can reduce number of code lines.
Upvotes: 1
Reputation: 125488
Just need to use the TimeSpan.TotalDays
property
TimeSpan totaldays = endtime.Subtract(starttime);
double tdays = totaldays.TotalDays;
Upvotes: 11