DATETIME_FORMAT extract hour

I’m trying to extract the hour from a datetime column. When I use datetime_format(field('date'), 'HH') it seems to extract the AM time of a 24hr entry.
EXAMPLE:
image

FORMULA: datetime_format(field('date'), 'HH')

Any ideas or a better way to extract the hour?

My end goal is to have a column say true or false if the time is between 00:00 and 06:00.

Thanks!

Under the hood datetime_format is just wrapping the to_char Postgresql function, see PostgreSQL TO_CHAR Function By Practical Examples for more details. For you specific use case I believe you should instead use HH24 to get the 24 based hour. Hope this helps!

1 Like

Thank you that worked!