Find last sunday

Adu picture Adu · Nov 25, 2009 · Viewed 18.4k times · Source

How will you find last sunday of a month in sql 2000?

Answer

gbn picture gbn · Nov 25, 2009
SELECT
 DATEADD(day,DATEDIFF(day,'19000107',DATEADD(month,DATEDIFF(MONTH,0,GETDATE() /*YourValuehere*/),30))/7*7,'19000107')

Edit: A correct, final, working answer from my colleague.