GSquared (4/24/2009)
Before you start stuffing the string, make sure that times before 10 AM are stored with leading zeroes. If not, you might have a problem when 9:00 AM tries to turn into the hour 90.
Hmm, good point.
How about this?
select convert(char(8),
convert(datetime,
convert(datetime, stuff(stuff(right('0' + '154040',6),3,0,':'),6,0,':')) -
convert(datetime, stuff(stuff(right('0' + '133737',6),3,0,':'),6,0,':'))),
108)
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes