musosdev
10/23/2008 8:19:00 AM
Peter,
Thanks for help... TotalHours is exactly what I needed to avoid the
calculation entirely!
Cheers
Dan
"Peter Duniho" wrote:
> On Wed, 22 Oct 2008 11:19:01 -0700, musosdev <musoswire@community.nospam>
> wrote:
>
> > Hi guys
> >
> > I need to do some calculations based on a TimeSpan object.
> >
> > The TimeSpan object is created from StartTime and EndTime (both DateTime
> > objects), and contains for example "02:00" to indicate 2 hrs.
>
> No, it doesn't. You would only get "02:00" if you converted the TimeSpan
> to a string. Until you do that, the TimeSpan is an exact representation
> of some specific length of time.
>
> > I need to perform the following calculation on the TimeSpan
> >
> > TimeSpan/(1/24)
>
> Why?
>
> > This works in Excel in a Date/Time field, but I can't find ANY ConvertTo
> > that will allow me to perform this calculation, presumably because the
> > TimeSpan includes : ??
>
> In Excel, a time value is represented in terms of days or fractions of
> days. If you wanted to convert a time value in Excel to hours, it would
> not be unusual at all to multiply it by 24, as you've shown above.
>
> But in .NET, if you have a TimeSpan value and you want to get the number
> of hours it represents, you can just retrieve the TimeSpan.TotalHours
> property.
>
> Pete
>