Solved

How to add 1month,6month and 1 years from today's date.

Posted on 2011-09-14
5
328 Views
Last Modified: 2012-05-12
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
Comment
Question by:Itgirl16
5 Comments
 
LVL 24

Expert Comment

by:johanntagle
ID: 36540453
0
 
LVL 39

Expert Comment

by:appari
ID: 36540484
SELECT DATEADD(mm, 1, getDate) After1Month,
DATEADD(mm, 6, getDate) After6Month,
DATEADD(yy, 1, getDate) After1Year

 
0
 
LVL 39

Accepted Solution

by:
appari earned 500 total points
ID: 36540492
sorry i missed (),
try this

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

0
 
LVL 15

Expert Comment

by:Anuj
ID: 36540752
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
 
LVL 21

Expert Comment

by:Alpesh Patel
ID: 36542589
DAteAdd(d,noofdays,getdate())
DAteAdd(m,noofmonths,getdate())
DAteAdd(y,noofyears,getdate())
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Suggested Solutions

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now