Skip to content

Instantly share code, notes, and snippets.

@raven-rock
Created October 12, 2018 14:25
Show Gist options
  • Save raven-rock/692ac2347c108d94cef2b2335bfc40ba to your computer and use it in GitHub Desktop.
Save raven-rock/692ac2347c108d94cef2b2335bfc40ba to your computer and use it in GitHub Desktop.
Redshift: derive week starting Sunday date from a date or timestamp value
select
(date_col - (extract(dow from date_col) || ' day')::interval)::date as week_of_starting_sunday
from
mytable
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment