Produced example:
DECLARE @StartDate DATETIME, @EndDate DATETIME
SET @StartDate = '2010-01-01 00:00:00.000'
SET @EndDate = DATEADD(m, 1, @StartDate)
SELECT @StartDate, @EndDate - 1
Basically you want to take the start date, add one month (which does DATEADD), and then subtract one day.
The result of this query:
StartOfMonth EndOfMonth
----------------------- -----------------------
2010-01-01 00:00:00.000 2010-01-31 00:00:00.000
source
share