Puruganti Ramesh wrote: > Hi Friends, > > I have an issue in comparing dates in python 2.7.8 > I have written code as below but i am getting error > Code is : > 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
No, the above does not trigger the ValueError. > 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 See my answer on comp.lang.python: <https://mail.python.org/pipermail/python-list/2015-February/698959.html> _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
