Link to home
Start Free TrialLog in
Avatar of robthomas09
robthomas09

asked on

SQL subtract two times to get minutes - SQL Server 2008

Hello experts.

I have two string variables that I need to subtract to find their times, and need some help with the syntax please.

DECLARE @S1 varchar(10)  = '09:15 AM'
DECLARE @S2 varchar(10)  = '10:15 AM'
DECLARE @S3 int

set @S3 = @s1 - @s2

select @s3 -- would like the answer to be 60 (minutes).

Thoughts?

Thanks

ASKER CERTIFIED SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of robthomas09
robthomas09

ASKER

Thanks!