0

On a MySQL table the Date column is set at YYYY-MM-DD with some dates shown as 0000-00-00
(Default set at NULL) where no date is available. This is OK until I display the web page that contains the php code for the SELECT query.

All the 0000-00-00 dates are displayed on the html page as 1970-01-01.

I have tried in MySQL inserting something like 0 but cannot. Apparently inserting 'blank' is not an option.

I just want to display a blank field or 0000-00-00.
Does this require php or mysql intervention and what exactly ?

2
Contributors
1
Reply
3
Views
5 Years
Discussion Span
Last Post by cereal
0

Time stamps in mysql are saved in unix time, which is of seconds between the date you specify and 1970-01-01. In your query you can write:

SELECT fieldA, IF(strcmp(fieldB,'0000-00-00'),fieldB,'0') AS 'fieldB' FROM mytable;

bye

Edited by cereal: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.