Skip to content

Instantly share code, notes, and snippets.

@s0ren
Created January 28, 2014 09:07
Show Gist options
  • Save s0ren/8664400 to your computer and use it in GitHub Desktop.
Save s0ren/8664400 to your computer and use it in GitHub Desktop.
This is how to select things that are within the latest three months, excluding this current one.
SELECT * FROM Albums
WHERE dato
between
DATEADD(month,-3, DATEADD(DAY,-(DATEPART(DAY, GETDATE()))+1, GETDATE()))
and
DATEADD(DAY,-(DATEPART(DAY, GETDATE()))+1, GETDATE());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment