Skip to content

Instantly share code, notes, and snippets.

@isogram
Created May 13, 2016 10:29
Show Gist options
  • Save isogram/c5fd87ec447c32ca73d3a32c6e47beb2 to your computer and use it in GitHub Desktop.
Save isogram/c5fd87ec447c32ca73d3a32c6e47beb2 to your computer and use it in GitHub Desktop.
Get Date Range From Week Number
select
STR_TO_DATE(concat(tgl, ' Monday'),'%x%v %W') date_start,
STR_TO_DATE(concat(tgl, ' Sunday'),'%x%v %W') date_end
from
(
select
date_format(updated_at, "%Y%v") as tgl,
count(1) as counter
from table
group by tgl
) as c;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment