0

My goal is to check if a LocalDate is part of the current week. Similar examples for year and month startDate.month().eq(LocalDate.now().getMonthValue()); startDate.year().eq(LocalDate.now().getYear());

Ex 1 : 10 - Jun - 2021 (current day) is part if the 7 Jun - 13 Jun. Ex 2 : 6 - Jun - 2021 is not part of the current week.

1 Answers1

1

What about:

date.year().eq(DateExpression.currentDate().year())
   .and(date.week().eq(DateExpression.currentDate().week()))
  • org.postgresql.util.PSQLException: ERROR: function week(date) does not exist Hint: No function matches the given name and argument types. You might need to add explicit type casts. Any suggestions? – Andrei Craciun Jun 10 '21 at 13:05
  • 1
    When using PostgreSQL, make sure to use `PostgreSQLTemplates` with your queries so that the appropiate SQL is being generated: https://github.com/querydsl/querydsl/blob/master/querydsl-sql/src/main/java/com/querydsl/sql/PostgreSQLTemplates.java#L117 – Jan-Willem Gmelig Meyling Jun 10 '21 at 13:07