Converting seconds – SQL
16Jun09
For those works with many databases… mssql, oracle, sybase, progress sometimes has troubles with migrations.
The Date/Time types sometimes are a big problem.
This tip is how to convert seconds.
– Convert date to seconds
select (datepart(hour,getdate()) * 3600)
+ (datepart(minute,getdate()) * 60)
+ (datepart(second,getdate()))
– Convert seconds to HH:MM:SS
select convert(varchar,44235/3600)
+ “:”
+ convert(varchar,(44235 % 3600) / 60)
+ “:”
+ convert(varchar,44235 % 60)
Tip very useful…
That’s all… keep rocking!!!!
Filed under: Sql | Leave a Comment
Tags: ase, Convert, Date, datepart, example, hh:mm:ss, hour, microsoft, minute, mssql, second, Server, Sql, Sybase, T-Sql, time

No Responses Yet to “Converting seconds – SQL”