Since you are determined to run it in a loop, this is as good a method as any other.
BTW, you ought to remove your "IF" statement... with it, you're not getting all dates.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes