Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-09-14
5
Medium Priority
?
379 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 2000 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

704 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