Add One or More Days to Date in SQL Server

Day can be added to date or datetime in sql server using the following function.

Function :

DATEADD( datepart, number, date )

Arguments :

datepart : It is the part of date ( ex : day - for adding days to the date specified in 3rd argument )

number : It is an integer which is added to the datepart ( ex : day ) of date

date : date , to which we want to add number of days

Examples  :

1. Add 2 days to date : 2014-09-24

OUTPUT

( 2014-09-24 ) + 2 days
----------------------------
2014-09-26 00:00:00.000

 

2. Getting today and tomorrow ( today + 1 day )

OUTPUT
      Today                       Tomorrow
----------------------------------------------------
2014-09-25 23:56:43.757      2014-09-26 23:56:43.757

References :

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

 

 

Submit a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

www.000webhost.com