admin管理员组文章数量:1794759
redshift DATE
redshift DATE_TRUNC函数 查询日期上个月的26号到当前月的26号
代码语言:javascript代码运行次数:0运行复制# redshift脚本
# 2023-08-01 00:00:00.000
select DATE_TRUNC('month',current_date - INTERVAL '2 month')
# 2023-08
select left(DATE_TRUNC('month',current_date - INTERVAL '2 month'),7)
# 2023-08-26
select date(left(DATE_TRUNC('month',current_date - INTERVAL '2 month'),7)+'-26')
# 上上个月26号到上个月的26号
select date(left(DATE_TRUNC('month',current_date - INTERVAL '2 month'),7)+'-26')
# 2023-09-26
select date(left(DATE_TRUNC('month',current_date - INTERVAL '1 month'),7)+'-26')
# 正解
# 2023-09-26
select date(left(DATE_TRUNC('month',current_date - INTERVAL '1 month'),7)+'-26')
# 2023-10-26
select date(left(DATE_TRUNC('month',current_date - INTERVAL '0 month'),7)+'-26')
# 正解
# 2023-10-01 00:00:00.000
select DATE_TRUNC('month',current_date)
# 2023-10
select left(DATE_TRUNC('month',current_date),7)
# 2023-10-26
select date(left(DATE_TRUNC('month',current_date),7)+'-26')
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。 原始发表:2023-10-28,如有侵权请联系 cloudcommunity@tencent 删除dateselect函数脚本本文标签: redshift DATE
版权声明:本文标题:redshift DATE 内容由林淑君副主任自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.xiehuijuan.com/baike/1754975537a1708910.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论