I want to fetch data according to month. Date is stored in timestamp.
select pdate,COUNT(*) from qchat_sessions WHERE month(pdate)='09'
i am using this query but thats not working correctly.
and how to echo the date from time stamp
Thanks
EDIT1
Mainly what i want to do is to echo the dates from that month with no of rows. in db i have two dates : 2013-09-27
and 2013-09-28
but using:
`$sss=mysql_query("SELECT DATE(pdate),COUNT(*) FROM qchat_sessions WHERE MONTH(pdate)='09'"); $rows = mysql_fetch_array($sss); $a = array($rows[0],$rows[1]);
foreach ($a as $b)
{
print $b . " ";
It echos only 1 date may be i am missing something. } `
SELECT DATE(pdate) as pdate,COUNT(*)
FROM qchat_sessions
WHERE MONTH(pdate)='10';
EDIT
SELECT DATE(pdate) as pdate,COUNT(*)
FROM qchat_sessions
WHERE MONTH(pdate)='10'
GROUP BY DATE(pdate);
EDIT
You can use this code printing the data. Edit as your wish
while ($row = mysql_fetch_array($sss)) {
echo $row[0];
echo $row[1];
}
Try this:
select pdate,COUNT(*) from qchat_sessions WHERE month(FROM_UNIXTIME(pdate))='10'