• Can't get this to work.

    How r u setting the parameter? Let me explain it.

    For example if you need date for 3rd Sunday of March 2009 then use as follows

    SELECT dbo.getDateAtNthOccurence('01/Mar/2009',1,3)

    The output will be 2009-03-15 (15th march 2009)

    The first parameter is any date of month/year for which we want the occurrence date.

    The second parameter is as follows (if you need sunday then send 1 as parameter value):

    1:Sunday, 2:Monday, 3:Tuesday, 4:Wednesday, 5:Thrusday, 6:Friday, 7:Saturday

    The third parameter is as follows (if you need 3rd sunday then send 3 as parameter value):

    1:First, 2:Second, 3:Third, 4:Fourth, >4:Last

    hope this will help you to get the output.

    cheers 🙂