Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add hours to the result of SQL Server's `GetDate()` function? [closed]

Tags:

I want to add 2 hours to the result of getdate() in SQL SERVER. I know that I can add one day with:

select getdate() + 1 

But how is this done when wanting to add on hours onto getdate()?

like image 877
PicksAndPony Avatar asked Jul 13 '12 06:07

PicksAndPony


People also ask

How do I add hours to a timestamp in SQL?

The ADDTIME() function adds a time interval to a time/datetime and then returns the time/datetime.

How can I add hours and minutes in SQL Server?

For your calculation to work you would need 23.983333333*60. I would suggest using for ultimate accuracy (23*60)+59 = 1439. Making the final query "SELECT DATEADD(MINUTE, 1439, CAST('2016-07-08' AS DATETIME))".

How can add 15 days to current date in SQL Server?

SQL Server DATEADD() Function The DATEADD() function adds a time/date interval to a date and then returns the date.


1 Answers

select dateadd(hour,2,getdate()) 
like image 158
Madhivanan Avatar answered Sep 27 '22 18:09

Madhivanan