simplesystems
simplesystems

Reputation: 849

Spring MongoRepository filter string date column

Is it possible to filter a MongoRepository in Spring where there is a column with date strings like that:

2019-01-01T00:00:00
2022-01-20T00:00:00
2022-05-01T00:00:00

I try to get all columns where the Date value is after a certain date.

I tried the following statements:

findAllByPersonIdAndDateAfter(int id, Date after);

findAllByDateAfter(Date date)

findAllByDateGreaterThan(Date date);

Invoked it with e.g.:

Date after = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2022-03-31 23:00:00");
repository.findAllByDateAfter(after)

But it always returns 0 rows.

Upvotes: 0

Views: 44

Answers (0)

Related Questions