Wizard
Wizard

Reputation: 11265

compare dates in oracle

For example I have in table row finish with values:

20-JAN-06;
21-SEP-06;
12-FEB-10;
15-MAR-09;
03-JUL-09;
23-JAN-09;

How can I compare them against sysdate? I know that this code is not correct:

Select name from project where finish <= sysdate ;

Upvotes: 2

Views: 365

Answers (3)

Dave Richardson
Dave Richardson

Reputation: 4985

Select name 
from project 
where to_date(finish, 'DD-MON-YY') <= trunc(sysdate)

Upvotes: 2

StuartLC
StuartLC

Reputation: 107237

Why not use the ANSI standard CURRENT_TIMESTAMP?

SELECT * FROM SomeTable WHERE Finish <= CURRENT_TIMESTAMP;

Fiddle here

Upvotes: 1

Jester
Jester

Reputation: 3317

Something like that try cos I don't have oracle to test it

SELECT EMP_NAME, EMPNO
FROM EMP
WHERE TRUNC(START_DATE)  = TRUNC(SYSDATE);

or

SELECT emp_name, empno
FROM emp
WHERE start_date >= TRUNC(SYSDATE) 
    and start_date  < TRUNC(SYSDATE)+1

Upvotes: 1

Related Questions