Odoo Help


How to count total hours with exclude specific day between two datetime field in calculation ?

Ankit H Gandhi(AHG)
on 11/5/15, 6:00 AM 844 views

Hello People,

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


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..

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'])
on 11/7/15, 3:16 AM

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

Vale Trood
on 11/7/15, 7:20 AM

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

Ankit H Gandhi(AHG)
on 11/8/15, 4:39 AM

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

Ankit H Gandhi(AHG)
on 11/8/15, 4:41 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 11/5/15, 6:00 AM
Seen: 844 times
Last updated: 11/8/15, 4:41 AM