I have a postgreSQL query that returns 'Late' when the given condition is met, currently, When i run below query I'm getting an error
SELECT
CASE WHEN CAST(so.scheduled_delivery_time AS date) < CURRENT_DATE OR CAST(so.scheduled_delivery_time AS date) = CURRENT_DATE AND DATETIME(so.scheduled_delivery_time) < DATETIME_SUB(datetime(current_datetime()), INTERVAL '3' HOUR) THEN 'Late'
END AS status
FROM
table1
Error
ERROR: function datetime(timestamp without time zone) does not exist Hint: No function matches the given name and argument types.
What I'm I missing?
Hey there — the simplest answer is that there is no function named DATETIME
. Also it looks like your values are already timestamps, so you can probably just do this:
so.scheduled_delivery_time < current_datetime() - INTERVAL '3' HOUR
A good starting point to find the available functions, is the fine manual . CURRENT_TIMESTAMP will give you the current timestamp and you can use it like this:
SELECT CURRENT_TIMESTAMP;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.