0

I am trying to calculate the amount of time on a daily basis.

Currently I have calculated "[total hours per diem]", "[total days]" and the time values (if not split over multiple days).

Where I am having trouble is in calculating the total time spent if the event is not an "all day event" and falls over multiple days.

For example:

If I had 1/1/2013 12:00 PM (Start Date) and 1/2/2013 4:00 PM (End date). I would like to have the result be 8 hours ((4 hours per day day) * (2 days)). What I actually end up with is 28 hours (the difference between the two times).

It should be something like =([total days]*(*time difference of end time - start time)) but I can't figure out how to just pull the time for a single day.

Thank you in advance

0
var startDate = Convert.ToDateTime("1/1/2013 12:00 PM");
var endDate = Convert.ToDateTime("1/2/2013 4:00 PM");

var diffHours = (endDate.Hour - startDate.Hour);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.