Nov 26, 2014

Add minute, hour, day, month in date in sql server


--By using DATEADD(<interval>,<increment int>,<expression smalldatetime>) function we can add or reduce hour, day etc..



--For increment or decrement from the datetime the query are given below.



--For add minute  

DATEADD(MINUTE,20,GETDATE())

--For reduce minute 

DATEADD(MINUTE,-20,GETDATE())



--For add hour

DATEADD(HOUR,20,GETDATE())

--For reduce hour

DATEADD(HOUR,-20,GETDATE())



--For add day 

DATEADD(DAY,20,GETDATE())

--For reduce day  

DATEADD(DAY,-20,GETDATE())



--For add month   

DATEADD(MONTH,20,GETDATE())

--For reduce month

DATEADD(MONTH,-20,GETDATE())



--For add year   

DATEADD(YEAR,20,GETDATE())

--For reduce year 

DATEADD(YEAR,-20,GETDATE())