Reputation: 455
I want to check if current sysdate's day is greater than 10.
By using sysdate function I get todays date, which is 2017.09.27. How can I check if 27 is greater than 10?
SELECT * from emp
where sysdate >= 'YYYY, DD, 10'
This is the only solution I can think of (it's ofcourse incorrect). Thanks for help.
Upvotes: 0
Views: 1980
Reputation:
You could extract the day from the date:
select [ ... ]
where extract(day from SYSDATE) > 10;
Upvotes: 1
Reputation: 1612
SELECT * from emp
where TO_NUMBER(TO_CHAR(SYSDATE, 'DD')) >= 10
Upvotes: 1
Reputation: 1293
Use 'DD' date format to convert sysdate to a character string which is the day part of the date. i.e. '26' for today. Convert that string to a number and compare to 10.
SQL> select 'greater than 10' from dual where to_number(to_char(sysdate,'DD')) > 10;
'GREATERTHAN10'
---------------
greater than 10
Upvotes: 1