Sorting dates in proper order


I am using the following command:
CONCAT(DATE_FORMAT(MIN(created), ‘%c/%e/%y’), ‘-’, DATE_FORMAT(DATE_ADD(MIN(created), INTERVAL 6 DAY), ‘%c/%e/%y’)) AS week_date_range,

and the output is placing december of 22 at the end of the bar chart :

But it should have december of last year at the begning. I tried adding a sort by transfermation on the week_date_range and it compounded the issue by putting december and the first week of 23 at the end of january:

Are there any other things I can try? I am grouping them by week, so the week number…now that I’ve said that…when we get to week 50 and 52 of this year, is it going to merge those between years?

notice the return type of CONCAT

It is string hence the issue. in your sort order of your query use something none string.

Did you try “order by MIN(created), DATE_ADD(MIN(created), INTERVAL 6 DAY)”?

Great Idea, when I do that, it gives only one bar for the first week range and totals all the data.

Apparently you cannot order and group :frowning:

put the order in the end of the query

1 Like

Thank you!!!

1 Like