• Here is another approach on the link below. Function F_TABLE_DATE is a multistatement table-valued function that returns a table containing a variety of attributes of all dates from @FIRST_DATE through @LAST_DATE. It was intended mainly to be able to load a date table, but is can also be used directly in a statement for those occasions when you want to go outside your standard ranges.

    This function has about 65 columns representing just about every date attribute I have ever had any need for. It does not include any Fiscal period attributes, since that is something that is usually specific to a particular organization.

    Date Table Function F_TABLE_DATE

    http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=61519