redshift DATE_TRUNC函数 查询日期上个月的26号到当前月的26号
# 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')
标签:26,redshift,month,date,DATE,select,TRUNC From: https://www.cnblogs.com/oktokeep/p/17793642.html