Solved

EASY ONE - TSQL - add a year to a date

Posted on 2003-11-27
4
2,149 Views
Last Modified: 2011-09-24
I am writing a sproc and simply need to add X years to a smalldatetime (X can vary from 1-10).

Anyone know the syntax?


cheers
n
0
Comment
Question by:niico
  • 2
4 Comments
 
LVL 26

Expert Comment

by:Hilaire
ID: 9833642
select dateadd(y, 1, getdate())

adds 1 year to current date

Hilaire
0
 
LVL 1

Accepted Solution

by:
beavis_shenzhen earned 50 total points
ID: 9835496
not feasible for SQL 2000
"select dateadd(y, 1, getdate())" just add one day to the date ,not one year.

it should be:
select dateadd(year, 1, getdate())
or
select dateadd(yy, 1, getdate())
0
 
LVL 26

Expert Comment

by:Hilaire
ID: 9835583
Yep !
Thks for correcting me beavis_shenzhen
0
 

Author Comment

by:niico
ID: 9837535
Thank you both - beavis gets points as supplied correct answer.

Thx again
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sql help 8 55
sql 2014,  lock limit 5 31
SQL Server 2012 - Merge Replication Issue 1 19
what are the unique tables in SQL master database 5 58
When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

776 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