DECLARE @StartDate DATETIME
DECLARE @TodaysDate DATETIME
SELECT @TodaysDate = CONVERT(DATETIME, CONVERT(CHAR(10), Getdate(), 101), 101)
--If it is April 1 or greater, then the StartDate is the current year
IF MONTH(@TodaysDate) >= 4 SELECT @StartDate = CONVERT(CHAR(4), YEAR(@TodaysDate)) + '0401'
--Otherwise, it's the previous year
ELSE SELECT @StartDate = CONVERT(CHAR(4), YEAR(@TodaysDate)-1) + '0401'
SELECT @StartDate AS StartDate, @TodaysDate AS EndDate
Comments
Post a Comment