German Varanytsya
German Varanytsya

Reputation: 397

How to compare timestamp with time using pl/sql?

I have parameter :dateSend which has type timestamp and I am trying to make this evaluation.

CASE WHEN :dateSend <=  TO_TIMESTAMP('14:00:00', 'HH24:MI:SS') THEN 0 ELSE 1 END A

It doesn't work. Maybe I should convert :dateSend to time? Like to_char(CAST(:dateSend AS DATE),'hh24:mi:ss') but it doesn't work.

I need to show 0 if time from :dateSend is smaller then 14.00.

Upvotes: 0

Views: 80

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 522751

It appears that you want to obtain records having a time component which is earlier than 14:00 hours (2pm). If so, then use this:

SELECT
    CASE WHEN EXTRACT(hour FROM :dateSend) < 14 THEN 0 ELSE 1 END AS A
FROM yourTable;

Upvotes: 2

Related Questions