PostgreSQL 生成指定日期下一个月的日期
(在Hologres中,不支持递归查询)
SELECTto_char(T, 'YYYYMMDD')::int4 AS date_int,date(T) AS date_str,date_part('year', T)::int4 AS year_int,date_part('month', T)::int4 AS month_int,date_part('day', T)::int4 AS day_in_month,date_part('doy', T)::int4 AS day_in_year,date_part('week', T)::int4 AS week_int,date_part('quarter', T)::int4 AS querter_int,T - (date_part('isodow', T) - 1 || ' days')::interval AS week_start,T + (7 - date_part('isodow', T) + 1 || ' days')::interval - INTERVAL '1 seconds' AS week_end,date_trunc('month', T) AS month_start,date_trunc('month', T + '1 months') - interval '1 seconds' AS month_end,now()
FROMgenerate_series(('${dd}')::date + INTERVAL '1 days', (date_trunc('month', '${dd}'::date + INTERVAL '2 months'))::date - INTERVAL '1 days', '1 days') AS T;
输入参数'2023-10-31',结果如下