SQL Server: how to convert INTEGER to TIME

I have a very simple solution. If you have a field in database in int format and you want to know how many seconds it’s, the query is:

SELECT CONVERT(char(5), DATEADD(second, AVG(Avg_time), ‘20150101’), 108) as myAverage
FROM         T_GoogleAnalytics_data
HAVING      (AVG(Avg_time) IS NOT NULL)

Leave a comment

Send a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.