Just for orientation, here is a quick T-SQL code to find out the next Fridays, that will be on 13th day of the month.
SET DATEFIRST 1 DECLARE @d DATE = GETDATE() WHILE (@d < '2099/01/01') BEGIN IF DATEPART(dw,DATEFROMPARTS(YEAR(@d), MONTH(@d), 13)) = 5 BEGIN SELECT @d AS Friday13 END SET @d = DATEADD(m,1,@d) END
I set datefirst = 1 just in case you might have any other regional/language setting, noting that week starts with monday. In accordance with this, I can part the date and look for 5th day of the week (which it will be friday in this case).
Can you come up with shorter function in T-SQL that it would list dates of next couple of Friday the 13th? For example with OVER clause, CROSS APPLY, JOIN, CTE or CURSOR? only imagination is the limit 🙂 Tally table can also be used.