I need a flexible search query in order to fetch the products created 1 hour ago from current date, I have tried this:
select * from {product} where {creationtime} < current_date - INTERVAL 1 HOUR
Also this:
final FlexibleSearchQuery flexibleSearchQuery = new FlexibleSearchQuery("SELECT {pk} FROM {Product} where {creationtime} < ?inputDate");
flexibleSearchQuery.addQueryParameter("inputDate", ZonedDateTime.now(ZoneId.systemDefault()).toInstant().minus(1, ChronoUnit.HOURS));
However, none of these solutions actually worked, the first one returns the products created in the interval of 1 hour but ignores the actual day and month, looks like it only takes in count the hours and minutes but ignores the dates.
You need to use > operator like below:
final FlexibleSearchQuery flexibleSearchQuery = new FlexibleSearchQuery("SELECT {pk} FROM {Product} where {creationtime} > ?inputDate");
flexibleSearchQuery.addQueryParameter("inputDate", LocalTime.now().minus(1, ChronoUnit.HOURS));
And don't forget about server and app timezone maybe different.