Reputation: 59
I got a spring application with a query that looks like that.
MATCH (d:Drug) WHERE toLower(d.tradingName) CONTAINS toLower({0}) OR toLower(d.expire) CONTAINS
toLower({0}) RETURN (d)-[]-() ORDER BY d.expire
d.expire is a string in my pojos so the query i posted sorts everyting alphabetical. Thats not what i want.
How is it possible to parse d.expire as a date and order the results as Dates ?
Upvotes: 0
Views: 62
Reputation: 67044
This may be a slight improvement on @TheTeacher's fine answer.
The =~
operator can be used with a regular expression to perform case-insensitive comparisons. Also, WITH
the clause is not needed.
WITH "(?i).*" + {0} + ".*" AS regex
MATCH (d:Drug)
WHERE d.tradingName =~ regex OR d.expire =~ regex
RETURN (d)--() ORDER BY datetime(d.expire)
Upvotes: 0
Reputation: 510
MATCH (d:Drug)
WHERE toLower(d.tradingName) CONTAINS toLower({0}) OR toLower(d.expire) CONTAINS
toLower({0})
WITH d , datetime(d.expire) as expiryDate
RETURN (d)-[]-() ORDER BY expiryDate
Upvotes: 1