Hybris灵活的搜索获取记录1小时前创建

发布于 2025-02-10 08:42:37 字数 555 浏览 1 评论 0原文

我需要一个灵活的搜索查询才能获取从当前日期开始1小时创建的产品,我也尝试了:

select * from {product} where {creationtime} < current_date - INTERVAL 1 HOUR

但是

  final FlexibleSearchQuery flexibleSearchQuery = new FlexibleSearchQuery("SELECT {pk} FROM {Product} where {creationtime} < ?inputDate");
        flexibleSearchQuery.addQueryParameter("inputDate", ZonedDateTime.now(ZoneId.systemDefault()).toInstant().minus(1, ChronoUnit.HOURS));
  

,这些解决方案实际上都没有奏效,第一个解决方案是返回1小时间隔所创建的产品但是忽略了实际的日子和月份,看起来它只需要计数时间和几分钟,但忽略了日期。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浮萍、无处依 2025-02-17 08:42:37

您需要使用&gt;操作员如下:

  final FlexibleSearchQuery flexibleSearchQuery = new FlexibleSearchQuery("SELECT {pk} FROM {Product} where {creationtime} > ?inputDate");
    flexibleSearchQuery.addQueryParameter("inputDate", LocalTime.now().minus(1, ChronoUnit.HOURS));

不要忘记服务器和应用时区也许有所不同。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文