I have the following query:
SELECT `date_created`, COUNT(`ID`) AS no_of_registration
FROM (
SELECT `id`,
DATE_SUB(DATE_ADD(MAKEDATE(from_unixtime(`created_on`,'%Y'), 7),
INTERVAL EXTRACT(WEEK FROM from_unixtime(`created_on`,'%Y-%m-%d')) WEEK),
INTERVAL WEEKDAY(DATE_ADD(MAKEDATE(from_unixtime(`created_on`,'%Y'), 1),
INTERVAL EXTRACT(WEEK FROM from_unixtime(`created_on`,'%Y-%m-%d')) WEEK)) -1 DAY)
as `date_created`
FROM `users` WHERE 1) x
GROUP BY `date_created`
HAVING `date_created` BETWEEN CURDATE() - INTERVAL 12 WEEK AND CURDATE()
This displays the data from the last 12 weeks using the date today. However, it only shows date_created
as the Monday date. I'd like to show every week as a date range. Example: 2017-11-27 - 2017-12-04
.
Is this possible? I need it to display in my graph using chart.js.
Thanks for you help. -Eli
您好,不确定我是否了解您的问题,但是如果您只希望星期一,可以在where语句中添加:
AND DAYOFWEEK(a.Date)=2
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.