with t as (
select curdate() as LAST_MODIFIED_DT union all
select curdate() - interval 1 day union all
select curdate() - interval 2 day union all
select curdate() - interval 3 day union all
select curdate() - interval 4 day union all
select curdate() - interval 5 day union all
select curdate() - interval 6 day
)
select
LAST_MODIFIED_DT
, DATE_SUB(DATE(t.LAST_MODIFIED_DT), INTERVAL DAYOFWEEK(t.LAST_MODIFIED_DT)-2 DAY) as the_monday
from t
Always a treat, sir!
If I'm tracing your logic, I think we're close, but I don't if we're quite there.
"some_field" would be the date the row in question was last modified. It could be a Sunday, it could be a Tuesday. The challenge is to use whatever date is in that field and establish the week that corresponds to that date.
So, say it was Tuesday of this week, which is 05-11-2021. That would be value the "modified_date" column. I need the date of every day in that week.
Monday: 05/10/2021
Tuesday: 05/11/2021
Wednesday: 05/12/2021
etc.
My quandary is that I don't know how to establish the week that corresponds to a date. In this example, since it's so close to the present, perhaps it's not that challenging. But if I'm looking at 02/12/2021 as the "modified_date" value, then I'm stuck.
Make sense?