I'm having trouble inserting datetime into mariadb using C.
t = time(NULL);
struct tm tm = *localtime(&t);
sprintf(curTime, "%d-%02d-%02d %02d:%02d:%02d", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
sprintf(sql, "INSERT INTO dataTable (sn, date, value_1, value_2) VALUES (%s,%s,%.1f,%.1f)", rxsn, curTime, temp, hud);
Output sql:
INSERT INTO dataTable (sn, date, value_1, value_2) VALUES (fb8e2ffb, 2022-09-18 19:04:28,21.6,61.1)
And I get this:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '19:04:28,21.6,61.1)' at line 1
I tried different combinations and still nothing. Thank you