Home > OS >  How to retrieve only LocalDate from LocalDateTime in Database(PostgreSQL)?
How to retrieve only LocalDate from LocalDateTime in Database(PostgreSQL)?

Time:10-16

I need to retrieve distinct LocalDate from LocalDateTime in database. I can use Spring data JPA or SQL native query.

CodePudding user response:

I think you can do something like this :

@Query(value="select * from posts where published_at Between ?1 And ?2", nativeQuery = true)
    Page<Posts> findAllPostsByPublishedDate(LocalDate dateFrom, LocalDate dateTo, Pageable pageable);

  • Related