SQL Server Performance

last day of month

Discussion in 'SQL Server 2005 Reporting Services' started by arkiboys, Jun 4, 2008.

  1. arkiboys Member

    How do I get the last day of the current month?
  2. FrankKalis Moderator

    DECLARE @dt datetime
    SELECT @dt = GETDATE()
    SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, @dt), 30)
  3. Madhivanan Moderator

    or
    DECLARE @dt datetime
    SELECT @dt = GETDATE()
    SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, @dt)+1, -1)
  4. johng New Member

    or
    if you need up to the last millisecond:
    DECLARE @dt datetime
    SELECT @dt = GETDATE()
    SELECT DATEADD(ms, -3, DATEADD(MONTH, DATEDIFF(MONTH, 0, GetDate()) + 1, 0))

    jg

Share This Page