You are missing the time in your datetime string. You are just inserting date which is throwing first error. You can solve this error by passing time with date string, see below example:

2015-01-20 00:00:00

Or you can use datetime module as below:

First make datetime object from the string:

datetime_obj = datetime.datetime.strptime('20-01-2015', '%d-%m-%Y')

Then while inserting this datetime object into database convert it into the datetime string by simply str function

datetime_str = str(datetime_obj)

Now use this datetime_str.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top