英文:
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 '1' DAY;
I have this query which I'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>
专注分享java语言的经验与见解,让所有开发者获益!
评论