Post subject: Convert Number of Seconds to 00:00:00 Format
There may be a time in your career where you are given a number of seconds and need to convert it to Hour:Minute:Second format. This is a pretty common task, and writing a client side solution for it is pretty simple. On the other hand, it's unnecessary thanks to some of SQL Server's intrinsic functions and date formatters:
So, let's say that you had a field called Total_Seconds and you needed to format is as mentioned above. Basically, this little code snippet can do it for you:
CONVERT(VARCHAR,DATEADD(s,Total_Seconds,'19000101'),8) AS 'Some Alias'
That's all there is to it!
_________________ sreenath@myanna.in
Users browsing this forum: No registered users and 0 guests
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum