Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- 客户关系管理
- e-Commerce
- 会计
- 库存
- PoS
- Project
- MRP
此问题已终结
You can use following method as reference. This is available in addons/hr_holidays/hr_holidays.py(Line 262 in odoo8)
def _get_number_of_days(self, date_from, date_to):
"""Returns a float equals to the timedelta between two dates given as string."""
DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"
from_dt = datetime.datetime.strptime(date_from, DATETIME_FORMAT)
to_dt = datetime.datetime.strptime(date_to, DATETIME_FORMAT)
timedelta = to_dt - from_dt
diff_day = timedelta.days + float(timedelta.seconds) / 86400
return diff_day
Hope this will helpful.
This also works.. :)
use it....
from datetime import datetime
d1='2014-11-15'
d2='2013-11-30'
d1 = datetime.strptime(d1, "%Y-%m-%d")
d2 = datetime.strptime(d2, "%Y-%m-%d")
print abs((d2 - d1).days)
相关帖文 | 回复 | 查看 | 活动 | |
---|---|---|---|---|
|
2
1月 24
|
1919 | ||
|
2
6月 22
|
3762 | ||
|
2
6月 18
|
5525 | ||
|
2
11月 16
|
12768 | ||
|
0
10月 23
|
2241 |