I have a column offset in db as varchar(50)
which contains a value such as 05:30:00
or -2:15:00
.
I need to add or subtract this value from another column which is a DATETIME
datatype as 2011-07-22 14:51:00
.
MySQL SUBTIME() FunctionThe SUBTIME() function subtracts time from a time/datetime expression and then returns the new time/datetime.
How to add Hours to DateTime in Sql Server? We can use DATEADD() function like below to add hours to DateTime in Sql Server. DATEADD() functions first parameter value can be hour or hh all will return the same result.
try something like -
select convert(datetime, '05:30:00') + 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