Teradata查询:从作为参数传递的日期中减去1天

huangapple 未分类评论44阅读模式
英文:

Teradata query: Subtract 1 day from a date passed as a param

问题

SELECT start_balance FROM customer_account_details WHERE snapshot_dt = :fromDate - INTERVAL '1' DAY;

我有这个查询,我正在尝试通过Hibernate-JPA执行它。 fromDate 作为参数传递,其格式为 LocalDate。 我想要一个条件,根据这个给定日期的前一天获取结果。然而,查询不起作用。有人可以指出问题在哪里吗?

错误:
Caused by: org.springframework.dao.InvalidDataAccessResourceUsageException: 无法准备语句;SQL [...]


<details>
<summary>英文:</summary>

    SELECT start_balance FROM customer_account_details WHERE snapshot_dt = :fromDate - INTERVAL &#39;1&#39; DAY;

I have this query which I&#39;m trying to execute via Hibernate-JPA. The `fromDate` is passed as a param and is in `LocalDate` format. I wanted to have a condition where I need the results from 1 day prior to the given date. However the query is not working. Can someone point out where the issue is?

    Error:
    Caused by: org.springframework.dao.InvalidDataAccessResourceUsageException: could not prepare statement; SQL [...]

</details>


huangapple
  • 本文由 发表于 2020年7月23日 22:14:40
  • 转载请务必保留本文链接:https://java.coder-hub.com/63056367.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定