user526206 user526206 - 1 year ago 95
SQL Question

How to extract hour from query in postgres

I have timestamp in my table and i want to extract only hour from it. I search and find a extract function but unable to use as a query. Do i need to convert first timestamp in varchar and then extract hour from it?
Here is my query:

select extract(hour from timestamp '2001-02-16 20:38:40') // example

actual query:

select extract(hour from timestamp observationtime) from smartvakt_device_report

Answer Source

The following should work

select extract(hour from observationtime) from smartvakt_device_report
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download