The timestamps my database returns are in this format:
'2022-11-25T17:54:29.819Z'
I want to do hour(timestamp) to return just the hour but get this error
'error:"function hour(timestamp with time zone) does not exist"'
How do I get around this? Thanks!
CodePudding user response:
Try the function extract(...)
:
select extract(hour from my_column) from my_table
CodePudding user response:
We can use EXTRACT
for that:
SELECT EXTRACT(HOUR FROM yourtimestamp) FROM yourtable;
Whether a Z occurs in the timestamp, doesn't matter, see db<>fiddle
See the documentation