Oracle use LIKE '%' on DATE

后端 未结 8 1873
灰色年华
灰色年华 2021-01-12 02:52

My table myTab has the column startDate, which has the datatype \"DATE\". The data in this column are stored like dd.mm.yyyy.

8条回答
  •  北海茫月
    2021-01-12 03:00

    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'
    

提交回复
热议问题