I have a field that contains time in seconds after midnight, however SQL Server will only display it as datetime yyyy-mm-dd hh.ss.xxx. I am trying to query this and convert the data to seconds after midnight, the way it should be, e.g. 01:00 would be 3600.
I have tried SELECT CONVERT(int, timefield) but the result is a column named (No column name) and values are -1 or -2.
What am I doing wrong here?
Thanks for any help!
Use the function DATEDIFF:
From http://www.eggheadcafe.com/software/aspnet/35057980/mssql-timetosec.aspx