Can someone help with a SQL function that takes four parameters (StartDate, EndDate, and DayOftheWeek, and Frequency) and returns the numberofPeriods are between these date range.
For example, If you pass the startdate as 05/12/2011, enddate as 06/12/2011, and DayOftheweek = Friday, and Frequency = Weekly) then it should calculate how many fridays are in between 05/12/2011 and 06/12/2011 on a weekly basis. In this example, there are 5 fridays between these date range.