Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DECLARE @StartDate datetime = '6/1/2015',
- @EndDate datetime = '6/30/2015'
- DECLARE @DayRange int = (select DateDiff(day,@StartDate,@EndDate))
- --This can be done differently, I made this negative
- SET @DayRange = - @DayRange
- --This is your temp table that will have all your dates in the range
- DECLARE @Temp Table
- (
- ID int IDENTITY(1,1),
- DataDate DateTime,
- DataValue int
- )
- --Fill the temp table with all the dates
- WHILE(@DayRange < 1)
- BEGIN
- INSERT INTO @Temp
- SELECT DateAdd(day,@DayRange,@EndDate),0
- SET @DayRange = @DayRange + 1
- END
- --Check out your temp table
- SELECT * FROM @Temp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement