Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
Hi, in my object I have two date fields: date1:fields.date('date 1'), date2:fields.date('date 2'),
I want to retrieve the difference of that 2 fields I tried this : date2 - date1 but I got this error : TypeError: unsupported operand type(s) for -: 'str' and 'str'
Hi mos, You need to do some python level stuffs with dates for getting exact date difference , i will explain with an example
from datetime import datetime fmt = '%Y-%m-%d' from_date = '2013-09-01' -> Take your date field1 to_date = '2013-09-31' -> Take your date field2 d1 = datetime.strptime(from_date, fmt) d2 = datetime.strptime(to_date, fmt) daysDiff = str((d2-d1).days) -> will gives you 29 days daysDiff = str((d2-d1).days + 1) -> will gives you 30 days
Hope it helps you ........ Thanks
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.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 9/18/13, 12:25 PM|
|Seen: 15524 times|
|Last updated: 2/27/18, 8:48 PM|