0

Test 1

Date        id
01-02-2011  1
01-08-2011  1
01-04-2012  1
01-02-2013  1
01-02-2015  1
01-05-2015  1
01-06-2015  1

I want a query that only checks for the year like

select Date, id from Test1 where Date like 2015;

So the output is:

Date        id
01-02-2015  1
01-05-2015  1
01-06-2015  1

2 Answers 2

3
select * 
from test1
where to_char(datecol,'yyyy')= '2015'
Sign up to request clarification or add additional context in comments.

Comments

3

If the date column has index, the best way I can think of is

select * 
from test1
where Date >= to_date('01-JAN-15','DD-MON-YY') and Date < to_date('01-JAN-16','DD-MON-YY') 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.