Home Forums SQL Server 2005 T-SQL (SS2K5) How to get week of a mont with input parameter date. RE: How to get week of a mont with input parameter date.

  • Luis Cazares (9/12/2012)


    In 2005 there are TVF (Table Valued Functions)

    There are not Table Value Constructors.

    Is that what you meant?

    It can be fixed by

    declare @TestDate date = '2012-09-12';

    with SevenRows(n) as (

    select row_number() over (order by (select null)) - 1

    from (SELECT TOP 7 NULL FROM sys.columns)dt(n)

    )

    select dateadd(dd, n,dateadd(wk,datediff(wk,0,dateadd(dd,-1,@TestDate)),0))

    from SevenRows;

    Now that I will agree with and can correct.

    Thanks, Luis.