Skip to Content
Menu
This question has been flagged
1 Reply
3472 Views

Hello People,

I want to total hours from two date with exclude specific day.

Like

start date = 2015-07-02 10:30:40

end date = 2015-07-04 08:40:25

in there is total hours is 46.1625

I want total hours in exclude specific day.

Thanks in advance..

Avatar
Discard

As we solved day count in another thread, we can build solution to this case on top of day count from there. for other days then "start day" and "end day", it's simply (24 * day_count) and we well have special cases for first and last day, so "total days" = "day count" * 24 + "hours in first day" + "hours in last day", that's it. check an implementation here , from functions defined there, you can use either "get_hours_by_weekdays" or "get_hours_weekday_exclude" for this purpose:

import weekday_time
dtt_start = "2015-07-02 10:30:40"
dtt_end = "2015-07-04 08:40:25"
# you can use either:
hours = get_hours_weekday_exclude(dtt_start, dtt_end, 'tue')
# or:
hours = get_hours_by_weekdays(dtt_start, dtt_end, ['mon','wed','thu','fri','sat','sun'])

hey friend did you find an answer to your question??

Author

Excellent !!! It's work good.. Many Many Thanks @ Temur. +1 and accepted.

Author

Yes, @ Drees Far. I got answer with help by Temur code..