Posted By

Abe on 02/12/08


Tagged

sql date null


Versions (?)

Date 0000-00-00


 / Published in: SQL
 

URL: http://www.estadobeta.com/2008/02/12/la-fecha-0000-00-00-de-mysql/

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
  3.  
  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.