Try this:
TimeSpan ts = TimeSpan.FromDays(value);
Question
So I have a webapp that calls a SQL package function that returns a number type in the form of d.(fraction of a day[up to two decimal places]).
So for example, 1.5 would translate to one and a half days.
I want to convert it to a timespan. From working with C#, there seems to be a fair amount of useful library functions, so I was hoping there might be some function I could call and do the conversion in a line or two. However, the closest thing I could find was Parse. However it only has an hour format of 0-23 hours rather than something that takes in fractions of days.
So is there some other function I could use or could I use some sort of hackery like this:
culture = new CultureInfo("d.(hh*24)"),
TimeSpan ts = TimeSpan.Parse(value, culture);
La solution
Try this:
TimeSpan ts = TimeSpan.FromDays(value);