How to calculate the difference between two dates in OpenERP?
问题 In my custom module I am unable to calculate difference between two dates. My field is 'date_s':fields.datetime('Start Date'), 'date_e':fields.datetime('End Date'), I want to calculate the difference automatically in my duration field: 'Duration':fields.char('Duration'), 回答1: this is a simple function I have written. Hope it will help you. def onchange_return_date(self, cr, uid, ids, issuedate, returndate): a=datetime.strptime(issuedate,"%Y-%m-%d") b=datetime.strptime(returndate,"%Y-%m-%d")