date function

  • i need to create a quarter function?

    Any one going to help me...

    Edited by - lital on 07/24/2003 03:07:07 AM

  • There's plenty of help available in this forum. What do you want the function to do? Can the "quarter" option in the DATEPART function help at all?


    Cheers,
    - Mark

  • group by year quarter

  • If you want to group by quarter, and year:

    select

    datepart(Q,Date),

    datepart(yy,Date),

    Count(*)

    from myTable

    group by datepart(Q,Date),datepart(yy,Date)

    else just quarter:

    select

    datepart(Q,Date),

    count(*)

    from myTable

    group by datepart(Q,Date)

    as mccork said: see BOL for Datepart

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply