MySQL Forums
Forum List  »  Connector/Python

Wrong date format in MYSQL after python insert
Posted by: Razvan Pop
Date: January 22, 2019 03:52PM


I have the following code in python to inset data in a MySql table:

sql = "INSERT INTO ap_temp_data (sensor, date, time, temp) VALUES (%s, %s, %s, %s)"
val = (sensor, time.strftime("%d.%m.%Y"), time.strftime("%H:%M:%S"), read_temp())
mycursor.execute(sql, val)

The problem is that the date for 22.01.2019 in MySql is like that: 2022-01-20

Any idea what is wrong ?

Options: ReplyQuote

Written By
Wrong date format in MYSQL after python insert
January 22, 2019 03:52PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.