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.

  • xRafo (9/11/2012)


    Hi,

    i have a question,

    How to get First week of a actual month?

    Please define what you mean by "first week of the month". For example, is it the actual first 7 days of the month regardless of which day of the week it starts on? Is it the week starting on Sunday (for example) that contains the first of the month even if it starts on a Saturday? Is it the week of the month starting on Sunday (for example) that contains at least the first 4 calendar days of the month (like ISO).

    What would you define as the first week of September 2012 and why (for example???)

    Now... all of that appears to be contrary to the rest of your request...

    In my procedure i will send a parameter date: Example

    input -> today()

    output <-

    10/09 | 11/09 | 12/09 | 13/09 | 14/09 | 15/09 | 16/09

    any help would be useful.

    If that's what you really want, then the other posters have already posted some dandy ideas on how to do that.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)