How to calculate date after 1 month currentDate

How can I calculate the date after the month of the current date.

Example if I have 04/19/2012 I want to receive 05/19/2012. Is there any function in sql that allows this?

I need to do the same for the year as on 04/19/2012, and set 04/19/2013

Greetings

+8
date sql sql-server-2008
source share
6 answers

You can use DATEADD (datepart, number, date)

as indicated here

Examples (thanks DarrenDavis)

per month:

select dateadd(m, 1, getdate()) 

per year:

  select dateadd(YY, 1, getdate()) 
+14
source share

Use dateadd () function

 SELECT dateadd(mm, 1, '19-Apr-2012') 
+1
source share

To add 1 month to the current date:

 SELECT DATEADD(m, 1, GETDATE()) 

To add 1 year to the current date:

 SELECT DATEADD(YY, 1, GETDATE()) 

For additional arguments see:

http://msdn.microsoft.com/en-us/library/ms186819.aspx

+1
source share

You can use DateAdd:

 select dateadd(m, 1, getdate()) select dateadd(yy, 1, getdate()) 

Internet search for other period indicators such as hour, minute, etc.

0
source share

Something like this should do the job

SELECT DATEADD (month, 1, '2012-04-19')

during a year

SELECT DATEADD (year, 1, '2012-04-19)

http://msdn.microsoft.com/en-us/library/ms186819.aspx

0
source share

You can use this request for 1 month in advance. This query works fine in oracle.

 select add_months(trunc(sysdate),1) from dual; 

Use this request for 1 year in advance

 select add_months(trunc(sysdate),12) from dual; 
0
source share

All Articles