Odoo Help


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


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 353 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??

Drees Far
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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


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