I need to be able to add a 0 left at the time that sql only takes 3 digits ie from midnight to 9 in the morning for the information to be sorted!
Because if not the information I have is in the following order 0:00 1:00 10:00 am 11:00 a.m. 19:00 2:00 20:00 ....
And what I want is for the hours to be sorted ... My idea would be to transform the datetime into varchar to increment 0 and then the correct time, but I can not find the tools to get it done ... Can anyone help me?
select [Hora]
case when len(cast([Hora] as varchar(4))) = 4 then '0' + cast([Hora] as varchar(2))
from [dbo].['Data16_Agosto-2016$']
(I'm sorry but I still do not know how to put the code with the code format here in overflow)