You have to use
DATEADD
Function of
SQL Server.
Syntax :
DATEADD(DatePart, Number, Date)
See below Command which will give you the correct result :
SELECT DATEADD(MONTH,1,DATEADD(DAY,-1,GETDATE()))
Or
DECLARE @TDATE DATETIME
SET @TDATE = '2013-10-05'
SELECT DATEADD(MONTH, 1, DATEADD(DAY,-1, @TDATE))
To dynamically set date as Parameter you can use
Parameterized SQL Query
and execute this query through code :
_mSqlCommand.CommandText = "SELECT DATEADD(MONTH, 1, DATEADD(DAY,-1, " & Date.Now.Date & "))"
Or in
ASP.Net/VB.Net
Dim _myDate As Date = "2013-10-05"
MsgBox(DateAdd(DateInterval.Day, -1, _myDate.AddMonths(1)))
I hope this will help you. :)