skip to Main Content

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!

2

Answers


  1. Try the function extract(...):

    select extract(hour from my_column) from my_table
    
    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search