In orientDB, how do you search for records for which the date is in a specific year?

In my OrientDB instance, entries have a property date

that is stored as java.util.Date

.

I would like to receive all documents written in a specific year. But I don't think what to write

SELECT FROM posts WHERE date.format('yyyy')=2012

      

This is the best way to do it. or that?

+3


source to share


1 answer


This query is very inefficient, a full table scan will be performed. Best to use (possible index can be used):

select from posts where date between '2012-01-01 00:00:00' and '2012-12-31 23:59:59'

      



Assumption: date is of type Date (Time)

+3


source







All Articles