Oracle use LIKE '%' on DATE Oracle use LIKE '%' on DATE sql sql

Oracle use LIKE '%' on DATE


To make a text search on the date you would have to convert the date to text.

It's more efficient if you calculate the first and last date for what you want to find and get everything between them. That way it's done as numeric comparisons instead of a text pattern match, and it can make use of an index if there is one:

SELECT * FROM myTab WHERE startDate >= DATE '2015-01-01' AND startDate < DATE '2015-02-01'


SELECT * FROM myTab WHERE TO_CHAR(startDate,'dd.mm.yyyy') LIKE '%01.2015'


If the field type is "DATE" then the value isn't stored as a string, it's a number managed by Oracle, so you have to convert it to a string:

SELECT * FROM myTab WHERE to_char(startDate, 'MM.YYYY') = '01.2015';

You can also use date ranges in SQL queries:

SELECT * FROM myTab WHERE startDate BETWEEN to_date('01.01.2015', 'DD.MM.YYYY') AND     to_date('31.01.2015', 'DD.MM.YYYY');