Anand
Anand

Reputation: 21320

Oracle timestamp comparison issue in SQL

Below query is returning null on running in Oracle

SELECT MAX(ROW_CREATION_TMSTP) 
FROM RULES_REPOSITORY 
WHERE rule_cd = 'LCC12G' 
  AND (TO_CHAR(expiration_dt,'DD-MON-YYYY HH24:MI:SS') > TO_CHAR(current_timestamp,'DD-MON-YYYY HH24:MI:SS'))

I have a single row in my table with the following values of columns
rule_cd = LCC12G
expiration_dt = '10-JUN-13 03.51.12.000000000 AM'
ROW_CREATION_TMSTP = 10-APR-13 03.51.12.000000000 AM

By looking at the values it should return value of ROW_CREATION_TMSTP given above but it is not returning.

Did I miss something?

Upvotes: 1

Views: 583

Answers (1)

SenthilPrabhu
SenthilPrabhu

Reputation: 659

SELECT MAX(ROW_CREATION_TMSTP)
FROM RULES_REPOSITORY
WHERE rule_cd = 'LCC12G'
AND expiration_dt > current_timestamp;

Will do good..!

Upvotes: 4

Related Questions