Date Difference issue in Python 2.7.8

Puruganti Ramesh puruganti.ramesh at gmail.com
Fri Feb 20 04:32:37 EST 2015


Hi,
I have an issue in comparing dates in python 2.7.8
I have written code as below but i am getting error 

import datetime as dt
from datetime import datetime 
from datetime import datetime, timedelta, date

dt_str='2014-5-11'
dt_strq='2014-9-11'

dt_datea = datetime.strptime(dt_str, '%Y-%m-%d').date()
dt_dateb = datetime.strptime(dt_strq, '%Y-%m-%d').date()
dt_diff = dt_dateb - dt_datea
print dt_diff.days

I am getting below excption
Traceback (most recent call last):
File "FunctionUpdate.py", line 204, in <module>
dt_dateb = datetime.strptime(dt_strq, '%Y-%m-%d').date()
File "/usr/local/lib/python2.7/_strptime.py", line 328, in _strptime
data_string[found.end():])
ValueError: unconverted data remains:

Kindly solve my issue

Regards,
Ramesh



More information about the Python-list mailing list