Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 383
  • Last Modified:

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
0
Itgirl16
Asked:
Itgirl16
1 Solution
 
appariCommented:
SELECT DATEADD(mm, 1, getDate) After1Month,
DATEADD(mm, 6, getDate) After6Month,
DATEADD(yy, 1, getDate) After1Year

 
0
 
appariCommented:
sorry i missed (),
try this

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

0
 
AnujCommented:
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)
0
 
Alpesh PatelAssistant ConsultantCommented:
DAteAdd(d,noofdays,getdate())
DAteAdd(m,noofmonths,getdate())
DAteAdd(y,noofyears,getdate())
0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now