Valdas S
Valdas S

Reputation: 455

SQL oracle how to check if current date's day is greater than concrete day

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

Answers (3)

user5683823
user5683823

Reputation:

You could extract the day from the date:

select [ ... ]
where extract(day from SYSDATE) > 10;

Upvotes: 1

Ted at ORCL.Pro
Ted at ORCL.Pro

Reputation: 1612

SELECT * from emp
where TO_NUMBER(TO_CHAR(SYSDATE, 'DD')) >= 10

Upvotes: 1

Bobby Durrett
Bobby Durrett

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

Related Questions