Link to home
Start Free TrialLog in
Avatar of Itgirl16
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
Avatar of johanntagle
johanntagle
Flag of Philippines image

SELECT DATEADD(mm, 1, getDate) After1Month,
DATEADD(mm, 6, getDate) After6Month,
DATEADD(yy, 1, getDate) After1Year

 
ASKER CERTIFIED SOLUTION
Avatar of appari
appari
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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(VARCHAR,GETDATE(),112))
 FROM CTE
 OPTION (MAXRECURSION 365)
Avatar of Alpesh Patel
DAteAdd(d,noofdays,getdate())
DAteAdd(m,noofmonths,getdate())
DAteAdd(y,noofyears,getdate())