I want to show invoices by week:
SELECT *
FROM invoice
WHERE WEEK(timestamp_column)=$week
I want to let my users choose the week from a dropdown menu that says
Week of 1 June
Week of 8 June
Week of 15 June
.
.
.
etc.
Where 1 June=First day of week(22)
8 June=First day of week (23)
etc.
Can anyone figure out how to SELECT the first day of every week of a month (or quarter or year)?
My ever-so-clever kludge is to populate a table I call daterange with all the days of the year(s).
Then I
SELECT min(date_column)
FROM daterange
group by week(date_column)
But isn't there a way to get the same results without the kludgey daterange table?