I would like to get the week beginning Monday's for a range of dates. I read over this SO post on how to do that and tried with
select
id,
install_date, -- leave it in to check and validate manually
cast(dateadd(day, -1*(DATEPART(WEEKDAY, install_date)-2), install_date) as DATE) as WeekStart
from someschema.sometable
This gives error:
SQL compilation error: error line 4 at position 32 invalid identifier 'WEEKDAY'
How can I get the week beginning Monday for each date in someschema.sometable.install_date
? I.e. I'd like to eventually group by weeks where weeks run Monday to Sunday and display as the Monday week beginning?