Skip to content

Instantly share code, notes, and snippets.

@nomeyer
Created February 12, 2016 17:41
Show Gist options
  • Save nomeyer/1aaf0aef1a86af2dcf8a to your computer and use it in GitHub Desktop.
Save nomeyer/1aaf0aef1a86af2dcf8a to your computer and use it in GitHub Desktop.
PostgreSQL syntax to add the day to a date column
case extract(isodow from ~~date~~)
when 1 then 'Mon ' || cast(~~date~~ as date)
when 2 then 'Tue ' || cast(~~date~~ as date)
when 3 then 'Wed ' || cast(~~date~~ as date)
when 4 then 'Thu ' || cast(~~date~~ as date)
when 5 then 'Fri ' || cast(~~date~~ as date)
when 6 then 'Sat ' || cast(~~date~~ as date)
when 7 then 'Sun ' || cast(~~date~~ as date)
end date
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment