Catch the time of formatted sql server database

Asked

Viewed 3,861 times

0

My database has a difference of 4 hours, support so far has not given a solution, so I would like to know how I can format the time out:

select 
CAST(HORA_FECHAMENTO AS datetime) as HORA_FECHAMENTO,
CONVERT(VARCHAR(05), DATEADD(hour, +4, getdate()), 108) AS 'HORA'
from TB_ESTRACAO 
where ID > 0

Exit:

1900-01-01 11:00:00.000 | 15:29

I need it that way:

11:00 | 15:29

inserir a descrição da imagem aqui

1 answer

1


It’s just the sign of + you don’t need. The rest is right.

select CONVERT(VARCHAR(5), CAST(HORA_FECHAMENTO AS datetime), 108) as HORA_FECHAMENTO,
CONVERT(VARCHAR(5), DATEADD(hour, 4, getdate()), 108) AS 'HORA'
from TB_ESTRACAO 
where ID > 0
  • Your answer is not correct

  • i need the output of formatted information, you just took the sign from +?

  • Ah, got it. I’ll edit the answer.

  • I think there was a communication problem, because I don’t want to concatenate the time,

  • adjust the question

  • True. Look now.

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.