DATEDIFF in JPQL Query

Hi,

Can how can we use below sql format in JPQL to find the last 7 days of user.
7 is dynamic variable it can be any no of days data that can be fetch.

DATEDIFF(DAY, C.DATE_TIME, CURRENT_TIMESTAMP) <= 7

Hello,

No, but you can use jpql functions:
https://docs.jmix.io/jmix/data-access/jpql-extensions.html#functions

Also you can use EntityManager or JdbcTemplate.

EntityManager:
https://docs.jmix.io/jmix/data-access/entity-manager.html

JdbcTemplate:
https://docs.spring.io/spring-framework/reference/data-access/jdbc/core.html#jdbc-JdbcTemplate

Regards,
Nikita

1 Like