JC Borlagdan JC Borlagdan - 1 year ago 70
SQL Question

How do I add Time in SQL?

So my data is

1:30 PM.
I want to have a Data when user selects a time, I want it to add 1hr 30mins to that and make the data as
1:30 PM - 3:00 PM
. I've been searching for an answer and tried some workarounds but i couldn't get it. BTW the datatype of my Time is
, because when I tried using the Time datatype I had some issues on inserting from C# to SQL

Answer Source
--this does a few things
-- 1) converts the time stored as a varchar to the time datatype
-- 2) adds 90 minutes
-- 3) converts the time result back to the varchar datatype

select convert(varchar(10), dateadd(mi, 90, convert(time, '1:30 PM')), 100)

--this will show a final result of "3:00PM"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download