I have the following code:
DECLARE @monthPassed VARCHAR(MAX)
SET @monthPassed = '2010'
DECLARE @yearPassed VARCHAR(MAX)
SET @yearPassed = '10'
DECLARE @TempDate DATETIME
SET @TempDate = CAST(@monthPassed + '/' + '1' + '/' + @yearPassed AS DATETIME)
DECLARE @TestDate DATETIME
SET @TestDate = DATEADD(MONTH, 1, @TempDate)
This makes @TestDate 11-02-10. How would I always make this return the first of the month instead?
Might have something to do with
@monthPassedand@yearPassedbeing inverted. Switching them, on my end, resolved the problem.Results in: