sql - 使用 Redshift 转换日期
问题描述
我正在创建一个月末变量,它适用于 postgres,但我必须在 Redshift 中重写它,任何线索为什么它向我显示以下错误?
数据库报告语法错误:Amazon Invalid operation: Interval values with month or year part is 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
推荐阅读
- laravel - The page has expired due to inactivity. Why?
- ios - Programmatically created tableview delegate not working
- python - PyQt4 QWebPage 设置 Qtimer 用于额外时间渲染 Javascript
- javascript - 使用Typescript在nodejs中读取文件
- java - 检查Java版本是否大于Java中的某个迭代?
- vba - End(xlDown) 单行
- angular - TrackBy reuse across nested ngFors (nested or 2d arrays)
- reactjs - G-WAN servlet 可以将 ReactJS 单页应用程序部署到浏览器吗?
- jquery - datetime picker and input hidden type
- graphql - Authorization for subscriptions Graphql (Absinthe) with token