Max Date

  • How do i find out the max date of a particular month in a table.

    I have a records in the table like this

    DATE

    ------

    01 Jan 2004

    02 Jan 2004

    05 Jan 2004

    07 Jan 2004

    04 Feb 2004

    06 Feb 2004

    19 Feb 2004

    04 Mar 2004

    28 Mar 2004

    03 Apr 2004

    05 Apr 2004

    My output should be something like this

    OUTPUT

    ---------

    07 Jan 2004

    06 Feb 2004

    28 Mar 2004

    05 Apr 2004

    I want a SQL statement that can do this for me

    Thanks

    Shankar

  • select datepart(mm,dt) as Month,max(datepart(dd,dt)) as MaxDay

    from table

    group by datepart(mm,dt)

    ------------

    Ray Higdon MCSE, MCDBA, CCNA

  • Forgot the year, you could group by datepart(yy,dt) as well and include it in your select

    ------------

    Ray Higdon MCSE, MCDBA, CCNA

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

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