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()
?
The ADDTIME() function adds a time interval to a time/datetime and then returns the time/datetime.
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))".
SQL Server DATEADD() Function The DATEADD() function adds a time/date interval to a date and then returns the date.
select dateadd(hour,2,getdate())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With