If anyone would be kind enough to review the below code that would be much appreciated. I'm looking for any flaws in my logic that would produce incorrect results given the descriptions of my three scenarios.
DECLARE @Scenario int
--Scenario 1
--It is a friday that is not the first friday of the month
--Scenario 2
--It is a friday that is the first friday of the month
--Scenario 3
--It is a friday that is the first friday of the month and it is also the first day of the month
DECLARE @DayOfWeek int --numerical representation of the day of the week
SET @DayOfWeek = DATEPART(dw,getdate())
DECLARE @DayOfMonth int --numerical representation of the day of the month
SET @DayOfMonth = DATEPART(day,getdate())
IF @DayOfWeek = 6 and @DayOfMonth > 7
BEGIN
SET @Scenario = 1
END
IF @DayOfWeek = 6 and @DayOfMonth <= 7
BEGIN
SET @Scenario = 2
END
IF @DayOfWeek = 6 and @DayOfMonth = 1
BEGIN
SET @Scenario = 3
END
PRINT getdate()
PRINT @DayOfWeek
PRINT @DayOfMonth
IF @Scenario IS NOT NULL
BEGIN
PRINT @Scenario
END
ELSE
BEGIN
PRINT 'It is not scenario 1, 2, or 3'
END