减去日期以获得剩余天数

时间:2014-04-09 05:41:57

标签: django date python-2.7 django-views timedelta

减去日期并找到余额天数并检查它是否大于零。

view.py

fee_start_date = form.cleaned_data['fee_start_date'] '''1994-01-01 format'''
fee_end_date = form.cleaned_data['fee_end_date'] '''1994-01-01 format'''

def date_check(start_date,end_date):
       rem = datetime.timedelta(start_date) - datetime.timedelta(end_date)
       if rem > 0:
            return False
       else:
            return True

0 个答案:

没有答案