Hi,
i want to subtract two dates and get the total hours of the TimeSpan
object that it's returned. For example, if the TimeSpan is of 2 days, the total hours are 48.
Thanks
Hi,
i want to subtract two dates and get the total hours of the TimeSpan
object that it's returned. For example, if the TimeSpan is of 2 days, the total hours are 48.
Thanks
Then you want the TotalHours
property of the TimeSpan
object:
DateTime today = DateTime.Today;
DateTime twoDaysAgo = today.AddDays(-2.0);
// returns 48.0
double totalHours = (today - twoDaysAgo).TotalHours;