How to convert milliseconds, seconds, or minutes to TIME in SQL Server

Views: 6.690
Reading Time: <1 minute

Hello people,
Good afternoon!

These last few days I'm a little out of time, but to keep up with updating here I will do another quick post demonstrating how to convert milliseconds, seconds or minutes to TIME in SQL Server.

Often in our routines, especially when we create routine execution logs measuring the time taken to process, we have to store these records in a TIME field or a string that simulates the behavior of the TIME data type (Ex: 00: 01: 08.57800)

However, the conversion, although simple, is not so trivial and raises a lot of doubts, especially in novice SQL Server developers who end up even using functions to do this task and applying it to large volumes of data, impairing query performance. For this reason, I decided to create this post to help with this question.

Query Result:
SQL Server - How to convert milliseconds, seconds, or minutes to TIME in SQL Server

To the next!

How to convert milliseconds milliseconds, seconds, or minutes to TIME in SQL Server, convert seconds minutes milliseconds to time

How to convert milliseconds milliseconds, seconds, or minutes to TIME in SQL Server, convert seconds minutes milliseconds to time