Transfer your datetime object to a date object. Once they are of the same type, a comparison will make sense.
if d2.date() == d1.date(): print "same date" else: print "different date"
In your case above: -
In [29]: d2 Out[29]: datetime.date(2012, 1, 19) In [30]: d1 Out[30]: datetime.datetime(2012, 1, 19, 0, 0)
So,
In [31]: print d2 == d1.date() True
All you needed for your case was to make sure that you execute the date method with parentheses () .
Calvin cheng
source share