The PostgreSQL function CURRENT_TIME returns the current time and time zone offset of the machine on which PostgreSQL is running. It is given as a value in the 'hh:mm:ss. nnnnnn+/-tz' format.
PostgreSQL EXTRACT() function The extract function() is used to retrieves subfields such as year or hour from date/time values. The source must be a value expression of type timestamp, time, or interval. The field is an identifier or string that selects what field to be extracted from the source value.
The following should work
select extract(hour from observationtime) from smartvakt_device_report
SELECT to_char(now(), 'HH24:MI:SS') hour_minute_second
The word timezone
is redundant (read: wrong). You just need to give the column's name. E.g.:
db=> select extract(hour from observationtime) from smartvakt_device_report;
date_part
-----------
19
(1 row)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With