I'm trying to calculate employee seniority in my report. The contract specifies the date of hiring and the end date. The difference gives the number of years in seniority. I have this formula which calculates it for me normally except that by generating the report for the month of February, I get errors probably because of the leap year. Here is the formula I use:
date_start = contract.date_start
date_end = contract.date_end
if not date_end :
date_end = date.today()
timedelta = date_end - date_start
result = int(str(timedelta/365)[:2])
Wondering how to do that properly in python!
Any help would be appreciated!