Dec 15, 2014

DATEADD function in SQL Server

Function DATEADD returns a new DATETIME value based on adding an interval to the specified date.
The syntax of the DATEADD date function is as follows:
DATEADD(<Datepart>,<Number>,<DATE>)
The <Datepart> parameter specifies on which part of the date to return a new value.
Valid values are
YEAR or YY,
QUARTER or QQ or Q,
MONTH or MM or M,
DAYOFYEAR or DY or Y,
DAY or DD or D,
WEEK or WK or WW,
WEEKDAY or DW or W,
HOUR or HH,
MINUTE or MI or N,
SECOND or SS or S ,
and MILLISECOND or ms.
<Number> use to increment or decrement of <datepart> for new date,
<DATE> parameter is an expression that returns a DATETIME or SMALLDATETIME value.

For Example Click Here


Some useful links is given below.
How to find first and last day of the previous month