Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
SELECT PROCEDURE f29 (@d DATE) AS
DECLARE @i int
SET @i=YEAR(DATEADD(M,-2,@d))
SET @i=@i+(4-@i%4)
IF @i % 100 = 0 AND @i % 400 0 SET @i=@i+4
SELECT DATENAME(W, @i)
I was already messing with T-SQL date functions, so I figured why not...