Extract hour from date problems

It seems extract hour from date always return 0

SELECT HOUR(CURRENT_DATE())

SELECT DATE_PART('hour',CURRENT_DATE())

current_date() only returns a date. If a date gets casted to a timestamp you will receive this:
select cast(current_date() as timestamp) → 2024-01-04 00:00:00.000

Instead of current_date(), you should use the now() function which is a timestamp and contains the time.

So this query would resolve your problem:
select hour(now())

1 Like

Thanks for your helping, obviously I misunderstood the date, Thanks again!