Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Convert HH:MM:SS into seconds

Author  Topic 

sudip_dg77
Starting Member

2 Posts

Posted - 2007-11-02 : 13:56:22
Hi,

I have an user input variable called @stop_time which takes input in the format of HH:MM:SS.

I need to convert it into seconds only.

declare @start_time datetime
set @start_time ='02:15:00'


How can I do that?

Can anyone help please?

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2007-11-02 : 14:36:30
You can try this

declare @start_time datetime
set @start_time ='02:15:00'

SELECT DATEDIFF(s,0,DATEADD(day,0,@start_time))

Jim
Go to Top of Page
   

- Advertisement -