Open source software security

Show Every (x)day for the Year

30 November -0001
/* This program shows every Monday, Tuesday, Wednesday, etc. for the year 2001, specified as jDayName */

DECLARE @tmpDay as integer
DECLARE	@tmpMonth as integer

/*These varchar's are used to hold the values used in constructing a datetime syntax varchar for datepart() */
DECLARE	@tmp as varchar(10)
DECLARE @tmp2 as varchar(10)
DECLARE @varcharMonth as varchar(10)

DECLARE @jDayName as varchar(25)
	/*jDayName is the name of the day you wish to find*/
	select @jDayName = 'Monday'
	select @tmpDay = 1
	select @tmpMonth = 1
WHILE @tmpMonth < 13
BEGIN
	WHILE (@tmpMonth=1 OR @tmpMonth=3 OR @tmpMonth=5 OR @tmpMonth=7 OR @tmpMonth=8 OR @tmpMonth=10 OR @tmpMonth=12)
	  BEGIN
		while @tmpDay < 31
			BEGIN
				select @tmp = @tmpDay
				select @varcharMonth = @tmpMonth
				select @tmp = (@varcharMonth + '-' + @tmp + '-2001')
				select @tmp2 = @tmp
				select @tmp = datename(weekday, @tmp)
				IF @tmp = @jDayName
					BEGIN
					print @tmp2 + ' is a ' + @jDayName
					END 
				select @tmpDay = @tmpDay+1
			END	
	  select @tmpMonth = @tmpMonth + 1
	  select @tmpDay = 1
	  END
	  
	WHILE @tmpMonth = 2
	  BEGIN
		while @tmpDay < 28
			BEGIN
				select @tmp = @tmpDay
				select @varcharMonth = @tmpMonth
				select @tmp = (@varcharMonth + '-' + @tmp + '-2001')
				select @tmp2 = @tmp
				select @tmp = datename(weekday, @tmp)
				IF @tmp = @jDayName
					BEGIN
					print @tmp2 + ' is a ' + @jDayName
					END
				select @tmpDay = @tmpDay+1
			END
	  select @tmpMonth = @tmpMonth + 1
	  select @tmpDay = 1	
	  END

	WHILE (@tmpMonth=4 OR @tmpMonth=6 OR @tmpMonth=9 OR @tmpMonth=11)
	  BEGIN
		while @tmpDay < 30
			BEGIN
				select @tmp = @tmpDay
				select @varcharMonth = @tmpMonth
				select @tmp = (@varcharMonth + '-' + @tmp + '-2001')
				select @tmp2 = @tmp
				select @tmp = datename(weekday, @tmp)
				IF @tmp = @jDayName
					BEGIN
					print @tmp2 + ' is a ' + @jDayName
					END
				select @tmpDay = @tmpDay+1
			END
	  select @tmpMonth = @tmpMonth + 1
	  select @tmpDay = 1	
	  END

END