New PredefinedDateIntervals : this year and last year


CUBA proposes some useful predefined date intervals (e.g last month, this month) but not last year and this year, while the JPQL macro is already there.

It’s not difficult to create such bean (example below) and by extending PredefinedDateIntervalFactory but these intervals could be there in standard. In our case we have several years of data on line for statistics so for daily operations the filter “current year” is standard by default.

public class LastYearPredefinedDateInterval extends PredefinedDateInterval {

    public LastYearPredefinedDateInterval() {

    public String getJPQL(String propertyName) {
        return String.format("@between({E}.%s, now-1, now, year)", propertyName);


thanks for the idea. You’re right, it will be easy to add it. The issue:

You could as well add “this week”, “last week”. A bit less easy because it means @between macro needs to be modified to handle weeks. But very useful for sales & back-office people following activity.