Date of month end

  • Does anyone no a way that I could code a query that would always give the last day of the crrrent month. Where it had 30 or 31 days.

  • Sure:

    DECLARE @d DATETIME

    SET @d = '2006-10-24'

    SELECT DAY(DATEADD(d, -DAY(DATEADD(m,1,@d)),DATEADD(m,1,@d))) AS 'Last day of the month'

    ******************
    Dinakar Nethi
    Life is short. Enjoy it.
    ******************

  • Thanks!

    Merry Christmas!

  • This works to give you the last day of the previous month, in case you wanted that:

    select getdate()-datepart(day,getdate())

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

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