Sdf19
Sdf19

Reputation: 127

Find all records from database where date is from - to

How can I return all entities in a list for specific date range or for current month if I've only a parameter

@CreatedDate
@Column(nullable = false, updatable = false)
private Instant createdAt;

The result I would like to get is a List of this entity where the createdAt is between from to or return it for the current month. Is there a possibility to perform those actions using just the repository without @Query or not, any ideas?

Upvotes: 0

Views: 54

Answers (1)

Jens Schauder
Jens Schauder

Reputation: 81907

You can use a @Query annotation and the SpEL support to calculate upper and lower bound for your date range.

Upvotes: 1

Related Questions