Created
November 22, 2016 13:26
-
-
Save robjbrain/0c8e43d6c29aac534579a9684fa95051 to your computer and use it in GitHub Desktop.
How to set datetime to null when accidentally set to '0000-00-00 00:00:00'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you've accidentally got '0000-00-00 00:00:00' in a datetime field you can't fix it with this: | |
UPDATE table SET datetime = NULL WHERE datetime = '0000-00-00 00:00:00' | |
# Because you'll get this error: | |
Incorrect datetime value: '0000-00-00 00:00:00' | |
# But you can fix it with this | |
UPDATE table SET datetime = NULL WHERE datetime = 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment