Adding or Substracting time spans from a DateTime SQL value
Database
3
Posts
2
Posters
0
Views
1
Watching
-
Hello every buddy, How can I add for example some minutes to a datetime type value and get result again as a datetime? Thank you so much, - Den --- "Art happens when you least expect it."
This example takes the current time and adds 5 minutes to it:
DATEADD(minute, 5, getdate())
The first arg is the date part (minute, hour, year, month, etc.) The second arg is the amount you want to add (or for negative values, subtract) The third argument is the source datetime.
-
This example takes the current time and adds 5 minutes to it:
DATEADD(minute, 5, getdate())
The first arg is the date part (minute, hour, year, month, etc.) The second arg is the amount you want to add (or for negative values, subtract) The third argument is the source datetime.