PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have this query which bring me the results for a counter weekly and displays the date.
I need for it to start at the start of every month (e.g. 01 May 2005), count the results for every week and then make the last date the end of the month (31st May 2005).
<?php
select DATE_FORMAT(DATE_SUB(h_date, INTERVAL WEEKDAY(h_date) DAY), \"%d/%m/%y\" ) AS start_of_week, DATE_FORMAT( DATE_SUB( DATE_ADD(h_date, INTERVAL 6 DAY ), INTERVAL WEEKDAY(h_date) DAY), \"%d/%m/%y\" ) AS end_of_week, DATE_FORMAT(h_date, \"%u %M %Y\") AS week, SUM(h_count) AS week_total,e.* FROM tbl_hitcounter e WHERE DATE_FORMAT(h_date, \"%M %Y\") = DATE_FORMAT(NOW(), \"%M %Y\") GROUP BY week ORDER BY week DESC
?>
SELECT YEARWEEK(h_date) AS yearweek, SUM(h_count) AS week_total
FROM tbl_hitcounter
WHERE UNIX_TIMESTAMP(h_date) >= $start AND UNIX_TIMESTAMP(h_date) < $end
GROUP BY YEARWEEK(h_date)
ORDER BY yearweek DESC