Last active
May 18, 2017 16:47
-
-
Save gugat/2a91e62db34ad5a1af5b4a21b9069f9b to your computer and use it in GitHub Desktop.
SQL Server Loop Date Range
This file contains hidden or 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 @fecha datetime; | |
| declare @fecha_busqueda varchar(8); | |
| set @fecha = '20170501'; | |
| while @fecha < '20170531' | |
| begin | |
| set @fecha = dateadd(day,1,@fecha); | |
| set @fecha_busqueda = convert(varchar, @fecha , 112) | |
| select * from tb where fecha = @fecha_busqueda | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment