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())

Related Posts

Fatal Error: Peer authentication failed for user "postgres", when trying to get pgsql working with rails.

Problem: Sometimes, we get the following error when trying to make a connection in Rails.  FATAL ERROR: Peer authentication failed for us...