Integer difference in python between two dates

You want to get the classmethod datetime.datetime.strptime(), then take the .days attribute from the resulting timedelta:

import datetime

mdate = "2010-10-05"
rdate = "2010-10-05"
mdate1 = datetime.datetime.strptime(mdate, "%Y-%m-%d").date()
rdate1 = datetime.datetime.strptime(rdate, "%Y-%m-%d").date()
delta =  (mdate1 - rdate1).days

So you have the datetime module, which has a datetime.datetime class, which in turn has a datetime.datetime.strptime() method on it. I also added calls to .date() to extract just the date portion (result is a datetime.date instance); this makes dealing with timestamps that differ slightly less than a multiple of 24 hours easier.

Demo:

>>> import datetime
>>> mdate = "2010-10-05"
>>> rdate = "2010-10-05"
>>> mdate1 = datetime.datetime.strptime(mdate, "%Y-%m-%d").date()
>>> rdate1 = datetime.datetime.strptime(rdate, "%Y-%m-%d").date()
>>> delta =  (mdate1 - rdate1).days
>>> print delta
0
>>> type(delta)
<type 'int'>

sign1['days'] = sign1['diff'] / np.timedelta64(1, 'D')

I had the same problem and it solved by uding the above statement. I hope it helps.