August 7, 2008 at 9:02 am
Comments posted to this topic are about the item ChangeDateTpFirstOfNextMonth
August 14, 2008 at 1:33 am
If your want to remove the time portion of the result you could use this - select dateadd(month,datediff(month,-1,getdate()),0)
August 14, 2008 at 5:12 am
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))
August 14, 2008 at 11:38 am
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