Skip to content

Instantly share code, notes, and snippets.

@mburbea
Last active November 7, 2019 16:47
Show Gist options
  • Save mburbea/ed4f6a7550edbf641463138fc1b0cc77 to your computer and use it in GitHub Desktop.
Save mburbea/ed4f6a7550edbf641463138fc1b0cc77 to your computer and use it in GitHub Desktop.
select dateadd(d,offset,eo_2_months)
from (
select last_day(dateadd(month,-2,CURRENT_TIMESTAMP),month)
) z(eo_2_months)
cross join (values(1),(2),(3),(4),(5),(6),(7))o(offset)
where dayofweek(dateadd(d,offset,eo_2_months))=3
order by 1
offset 0 rows fetch next 1 row only
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment