I have the following query in mysql:
SELECT title,
added_on
FROM title
The results looks like this:
Somos Tão J
The best bet is to group it by YEAR and then by MONTH. See below
SELECT Count(*), Date(timestamp) FROM title GROUP BY YEAR(timestamp), Month(timestamp)
Could you try this?
select count(*), DATE_FORMAT(timestamp, "%Y-%m-01")
from title
group by DATE_FORMAT(timestamp, "%Y-%m-01")
Please, note that MONTH()
can't differentiate '2013-01-01' and '2014-01-01' as follows.
mysql> SELECT MONTH('2013-01-01'), MONTH('2014-01-01');
+---------------------+---------------------+
| MONTH('2013-01-01') | MONTH('2014-01-01') |
+---------------------+---------------------+
| 1 | 1 |
+---------------------+---------------------+
select count(*), date(timestamp) from title group by MONTHNAME(timestamp)
select
count(*) as Count,
MONTH(timestamp)+"-"+YEAR(timestamp) as Month
from
title
GROUP BY
MONTH(tumestamp);
SELECT Count(*),
Date(timestamp)
FROM title
GROUP BY Month(timestamp)
Edit: And obviously if it matters to display the 1st day of the month in the results, you do the DATE_FORMAT(timestamp, "%Y-%m-01")
thing mentioned in some other answers :)