Last active
September 13, 2019 10:26
-
-
Save MarioBinder/858385523492576f22cb to your computer and use it in GitHub Desktop.
select a daterange #sql #date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare @selecteddate date = cast(getdate() as date); | |
SELECT * | |
FROM foo | |
WHERE Date >= DATEADD(day, 0, convert(date, @selecteddate)) and Date < DATEADD(day, 1, convert(date, @selecteddate)) | |
Examples | |
declare @selecteddate date = cast(getdate() as date); --today | |
declare @selecteddate date = cast(getdate() -1 as date); --yesterday |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment