How to convert to datetime.datetime in Python

According to this

PyMongo doesn’t support saving instances, since there is no BSON type for dates without times. Rather than having the driver enforce a convention for converting instances to datetime.datetime instances for you, any conversion should be performed in your client code.

So you can use datetime.combine to combine your and datetime.time(0, 0)

from datetime import date
from datetime import datetime
d =
datetime.combine(d, datetime.min.time())
comments powered by Disqus