Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
12367 Vizualizări
Cel mai bun răspuns

    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.

Imagine profil
Abandonează

This also works.. :)

Cel mai bun răspuns

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)

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
2
ian. 24
2371
2
iun. 22
4322
2
iun. 18
5895
2
nov. 16
13399
0
oct. 23
2714