kamal213 Posted June 6, 2011 Share Posted June 6, 2011 Hi Guyz, I have a customer statistics page on my PHP customer management system, which give information of how many customers are added on each day using the SQL COUNT(*). I would like to calculate the total number of customers added each week. Please I would really apprectiate your help, ideas and suggestions, let me know if you need to see some code for more info. Thanks alot Link to comment https://forums.phpfreaks.com/topic/238549-total-number-of-customers-per-week/ Share on other sites More sharing options...
WebStyles Posted June 6, 2011 Share Posted June 6, 2011 same thing, use COUNT(*) combined with `date` BETWEEN '$starDate' AND '$endDate' Link to comment https://forums.phpfreaks.com/topic/238549-total-number-of-customers-per-week/#findComment-1225828 Share on other sites More sharing options...
The Little Guy Posted June 6, 2011 Share Posted June 6, 2011 Something like this: select count(*) total, date_format(date_column, '%U') week from stats group by date_format(date_column, '%U'); Link to comment https://forums.phpfreaks.com/topic/238549-total-number-of-customers-per-week/#findComment-1225911 Share on other sites More sharing options...
kamal213 Posted June 6, 2011 Author Share Posted June 6, 2011 Thanks for getting back to me webstyle Great point! Would I be on the right track if I said $starDate = strtotime("$day-$month-$year -7 day"); and $endDate = strtotime("$day-$month-$year +7 day"); Link to comment https://forums.phpfreaks.com/topic/238549-total-number-of-customers-per-week/#findComment-1225912 Share on other sites More sharing options...
kamal213 Posted June 6, 2011 Author Share Posted June 6, 2011 Thanks The Little Guy, are total, date_format, and date_column fuctions of sql or its just an illustration? soz, you can tell i dnt kno much bout sql lol! Link to comment https://forums.phpfreaks.com/topic/238549-total-number-of-customers-per-week/#findComment-1225918 Share on other sites More sharing options...
The Little Guy Posted June 6, 2011 Share Posted June 6, 2011 they are all functions except for for: date_column, total, week date_column = the column name of your date total = renames count(*) to total week = renames date_format(date_column, '%U') to week Link to comment https://forums.phpfreaks.com/topic/238549-total-number-of-customers-per-week/#findComment-1225920 Share on other sites More sharing options...
kamal213 Posted June 6, 2011 Author Share Posted June 6, 2011 Guru!! It worked TLG! Genius Link to comment https://forums.phpfreaks.com/topic/238549-total-number-of-customers-per-week/#findComment-1225924 Share on other sites More sharing options...
kamal213 Posted June 6, 2011 Author Share Posted June 6, 2011 Jst 4 future ref TLG, Could do you know what the %U stands for. Thanks Link to comment https://forums.phpfreaks.com/topic/238549-total-number-of-customers-per-week/#findComment-1225928 Share on other sites More sharing options...
The Little Guy Posted June 6, 2011 Share Posted June 6, 2011 Could do you know what the %U stands for. I was waiting for that question The %U stands for the week number 00-53 (54 weeks in a year) using Sunday as the first day of the week. Full list: http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-format Link to comment https://forums.phpfreaks.com/topic/238549-total-number-of-customers-per-week/#findComment-1225932 Share on other sites More sharing options...
kamal213 Posted June 6, 2011 Author Share Posted June 6, 2011 Interesting! You learn somethang new everyday. Thanks for that TLG can I add you as a buddy? Link to comment https://forums.phpfreaks.com/topic/238549-total-number-of-customers-per-week/#findComment-1225935 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.