Time Question

S

Sean Fullerton

In C# if I want to know the time in hours (fractional as well) between two
times how would I do that?

Current code is as follows:
DateTime startTime =
DateTime.Parse(e.Row.Cells["StartTime"].Value.ToString());

DateTime endTime = DateTime.Parse(e.Row.Cells["EndTime"].Value.ToString());



TimeSpan totalTime = endTime.TimeOfDay - startTime.TimeOfDay;

Decimal test = totalTime.Minutes / 60;

Sean
 
H

Habib Heydarian [MSFT]

I think what you're looking for is the TimeSpan.TotalHours property.

HabibH.
 
S

Sean Fullerton

Thanks, I found that right after I posted this. I appreciate the post!

Sean

Habib Heydarian said:
I think what you're looking for is the TimeSpan.TotalHours property.

HabibH.

Sean Fullerton said:
In C# if I want to know the time in hours (fractional as well) between two
times how would I do that?

Current code is as follows:
DateTime startTime =
DateTime.Parse(e.Row.Cells["StartTime"].Value.ToString());

DateTime endTime = DateTime.Parse(e.Row.Cells["EndTime"].Value.ToString());



TimeSpan totalTime = endTime.TimeOfDay - startTime.TimeOfDay;

Decimal test = totalTime.Minutes / 60;

Sean
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top