我正在创建一个月末变量,它可以与 postgres 一起使用,但我必须在 Redshift 中重写它,任何线索为什么它会向我显示以下错误?
数据库报语法错误:Amazon Invalid operation: Interval values with month or year parts are not supported 详情:------------------------ ---------------------- 错误:不支持包含月份或年份部分的区间值代码:8001 上下文:i
select
(date_trunc('month', ("Date (id created)" + INTERVAL '1 month'))) as "EoM"
from id
最佳答案
Redshift 使用 dateadd 将时间间隔应用于时间戳
select date_trunc(month, ( dateadd(month,1,"Date (id created)"))) as "EoM"
from id
参见 https://docs.aws.amazon.com/redshift/latest/dg/r_DATEADD_function.html
关于sql - 使用 Redshift 转换日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61362026/