将复杂的时间戳过滤器从SQL转换为HQL

时间:2017-11-10 09:25:24

标签: sql hql

我必须翻译

AND <timestamp> BETWEEN (now()::date - interval '1 day' * (EXTRACT(DOW FROM now()::date) - 1) - interval '{{number_of_periods}} {{time_interval}}') AND (now()::date - interval '1 day' * (EXTRACT(DOW FROM now()::date) - 1))

从SQL到HQL - 我该如何实现?

谢谢!

1 个答案:

答案 0 :(得分:0)

答案:

AND CAST(<timestamp> AS TIMESTAMP) BETWEEN CAST(now() AS DATE) - INTERVAL '1' DAY * (EXTRACT(DOW FROM CAST(now() AS DATE)) - 1) - INTERVAL '{{number_of_periods}}' DAY * 7 AND (now() - INTERVAL '1' DAY * (EXTRACT(DOW FROM CAST(now() AS DATE)) - 1))