Itgirl16
asked on
How to add 1month,6month and 1 years from today's date.
I am writing stored procedure in my stroed procedure I need to add 1 month from today's date is there any function that I can use same way I want to add 6 month from today's date and 1 year from today's date.
Plese give me information regarding that I don't know that much sql
Plese give me information regarding that I don't know that much sql
For MySQL see http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-add
SELECT DATEADD(mm, 1, getDate) After1Month,
DATEADD(mm, 6, getDate) After6Month,
DATEADD(yy, 1, getDate) After1Year
DATEADD(mm, 6, getDate) After6Month,
DATEADD(yy, 1, getDate) After1Year
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
DECLARE @month TINYINT
SET @month = 1
;WITH CTE
AS (SELECT 1 AS ID, GETDATE() dt
UNION ALL
SELECT ID + 1, DATEADD(dd,ID,dt)
FROM CTE
WHERE DATEADD(dd,ID,dt) <= DATEADD(mm,@Month,dt)
)
SELECT CONVERT(DATETIME,CONVERT(V ARCHAR,GET DATE(),112 ))
FROM CTE
OPTION (MAXRECURSION 365)
SET @month = 1
;WITH CTE
AS (SELECT 1 AS ID, GETDATE() dt
UNION ALL
SELECT ID + 1, DATEADD(dd,ID,dt)
FROM CTE
WHERE DATEADD(dd,ID,dt) <= DATEADD(mm,@Month,dt)
)
SELECT CONVERT(DATETIME,CONVERT(V
FROM CTE
OPTION (MAXRECURSION 365)
DAteAdd(d,noofdays,getdate ())
DAteAdd(m,noofmonths,getda te())
DAteAdd(y,noofyears,getdat e())
DAteAdd(m,noofmonths,getda
DAteAdd(y,noofyears,getdat