Possible Duplicate:
SQL Count records within a month using a unix timestamp
I have a table like this
+--------+------------+ | id | datetime | +--------+------------+ | 1 | 1313405609 | | 1 | 1313144410 | | 2 | 1313405550 | | 1 | 1313405549 | +--------+------------+
datetime is php unix time, I want to group row by date(e.g. 20120517) and count every group items. Because the date of 1313405609,1313405550 and 1313405549 is 20110815, the result I want is:
+--------+------------+------------+ | id | datetime | Count | +--------+------------+------------+ | 1 | 1313405609 | 2 | | 1 | 1313144410 | 1 | | 2 | 1313405550 | 1 | +--------+------------+------------+
how can I do it with sql?
Use
FROM_UNIXTIMEto convert a unix timestamp to a datetime. Then useDATEto get only the date part: