MySQL DATE returns NULL

date, mysql

Solution

You're probably looking for

SELECT DATE(FROM_UNIXTIME(created)) FROM mytable WHERE 1 LIMIT 5

Problem

I have the following table structure: ``` uid | ... | created | ... int(10) | ... | int(10) | ... ``` `created` field is filled with timestamps; here are the results of query `SELECT created FROM mytable WHERE 1 LIMIT 5`: ``` created ---------- 1308122243 1308122243 1308552690 1309247417 1309254571 ``` But when I execute `SELECT DATE(created) FROM mytable WHERE 1 LIMIT 5`, I get strange NULL's: ``` DATE(created) ------------- 2013-08-12 2013-08-12 NULL NULL NULL ``` Why that happens?

Original source

Related problems