JC Borlagdan JC Borlagdan - 9 months ago 37
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

--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"