[Django]-MySQL Query error when run within Python but not when run directly

0👍

Marc B had it right.

When executed directly, you are getting the warnings, but probably not noticing:

mysql> SELECT * FROM mytable WHERE created > UNIX_TIMESTAMP(STR_TO_DATE('2012-09-10 00:00:00-05:00','%Y-%m-%d %k:%i:%s') - INTERVAL 1 DAY);
Empty set, 3 warnings (0.00 sec)

mysql> show warnings;
+---------+------+----------------------------------------------------------------------+
| Level   | Code | Message                                                              |
+---------+------+----------------------------------------------------------------------+
| Warning | 1292 | Truncated incorrect datetime value: '2012-09-10 00:00:00-05:00'      |
| Warning | 1292 | Truncated incorrect datetime value: '2012-09-10 00:00:00-05:00'      |
| Warning | 1292 | Incorrect datetime value: '1347148800' for column 'created' at row 1 |
+---------+------+----------------------------------------------------------------------+
3 rows in set (0.00 sec)

Leave a comment