DateDiff, y u no Pretty?

Sometimes you just need hh:mm:ss

I ran into a case when I needed to display some results in the HH:MM:SS format. We all know and love DATEDIFF, which gives you whole number results. Using DATEDIFF, I was getting results like this:

The results are all well and good, but that isn’t something that I would want to hand over to the end users. So, I did a bit of hunting and found what I was looking for over on The guy wanted to display milliseconds along with the rest of his results. That was overkill so, his script worked perfectly for me. Here is what I ended using:

The results come back in a nicer, easily readable format.


Rudy Rodarte is a SQL Server Database professional based in Austin, TX. Over his career, Rudy has worked with SSRS, SSIS, performance tuning troubleshooting. When away from Keyboard, Rudy goes to Spurs and Baylor Bear sporting events.

More Posts - Website - Twitter