How to get only time of timestamp?

Asked

Viewed 3,604 times

2

I have a column timestamp on my table and I need to get only the time of these values.

Example of how you are registered: 30.12.1899 17:03

Example of how I need to display through select: 17:00

I got it this way:

SELECT
  CASE 
    WHEN Char_length(Extract(hour FROM coluna)) <= 1 THEN '0' ||  Extract( hour FROM coluna )  || ':00' 
    ELSE Extract(hour FROM coluna) || ':00' 
  end AS "DATA"
FROM   tabela

There’s an easier way for me to get the same result?

NOTE: I only need the hour with two decimal places, the minutes will be fixed, that is, it will always be 00.

  • Man, I don’t understand the language in question, but analyzing programmatically, I think the code is already straight and easy.

1 answer

2


This way you extract the Minute and Second Hour from the Field date and timestamp of the Firebird see Here Complete Content about extracting date and Time from the field timestamp

SELECT EXTRACT (HOUR FROM tabela.Campo) ||
':' || EXTRACT (MINUTE FROM tabela.Campo) ||
':' || EXTRACT (SECOND FROM tabela.Campo) FROM tabela

Browser other questions tagged

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