Solved

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

Posted on 2011-09-14
5
373 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

623 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