Odoo Help

Welcome!

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.

0

how to calculate number of days worked by an employee between two dates?

By
SIEWE TIENTCHEU Marcelin
on 12/1/15, 3:43 AM 456 views

I created one salary rule for  seniority(antiquity: Number of days the employee has done in company)
 i have the join date (from contract) and today of the employee..

what i want is how many days  between that two date.

ie: number of working days between two dates

Please help me.

0

Ankit H Gandhi(AHG)

--Ankit H Gandhi(AHG)--
996
| 5 3 6
Rajkot, India
--Ankit H Gandhi(AHG)--

Learning Python..

Ankit H Gandhi(AHG)
On 12/1/15, 6:27 AM

Dear Marcelin,

Using below code you will get number of days.

from datetime import datetime

format = '%Y-%m-%d'

start_date = '2015-12-01' -> Take your date field1

end_date = '2015-12-31' -> Take your date field2

start = datetime.strptime(start_date, format)

end = datetime.strptime(end_date, format)

daysDiff = str((end-start).days) -> will gives you 30 days

daysDiff = str((end-start).days + 1) -> will gives you 31 days

Hope this code help for you !!!

Thanks & Regards,

Ankit H Gandhi.

0
HappyOdoo
On 12/1/15, 4:48 AM

subtract two dates 

if you are a developer then Use below query in your code :

select '2015-11-01'::date - '2015-11-30'::date-1; 

This will give you:

30 days 

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)

Stats

Asked: 12/1/15, 3:43 AM
Seen: 456 times
Last updated: 12/1/15, 6:30 AM