Posted By

Abe on 02/12/08


sql date null

Versions (?)

Date 0000-00-00

 / Published in: SQL


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

  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  

You need to login to post a comment.