ChangeDateTpFirstOfNextMonth

  • Comments posted to this topic are about the item ChangeDateTpFirstOfNextMonth

  • If your want to remove the time portion of the result you could use this - select dateadd(month,datediff(month,-1,getdate()),0)

  • Alternately, you can also use the DATEPART function instead of DATEDIFF:

    DECLARE @Date DATETIME

    SET @Date = GETDATE()

    SELECT DATEADD(MONTH,1,DATEADD(DAY, (-1 * DATEPART(DAY,@Date)) + 1, @Date))

  • You can truncate the time part and simplify the calculation in one swell foop:

    select DateAdd( m, DateDiff( m, 0, @NextMonth ) + 1, 0 );

    Leave out the "+ 1" and you get the first day of this month.

    Tomm Carr
    --
    Version Normal Form -- http://groups.google.com/group/vrdbms

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

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