Date 0000-00-00

/ Published in: SQL
Save to your folder(s)

An easy way to handle null dates. If date = 0000-00-00 then null, else use date

Copy this code and paste it in your HTML
  1. # Original SQL
  2. SELECT name, last_name, birthday FROM people
  4. #Modified SQL
  5. SELECT name, last_name, IF( birthday = '0000-00-00', NULL, birthday) AS birthday FROM people


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.