clear markdown compare help best fiddles feedback dbanow.uk a leap of faith?
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 2335744 fiddles created (27465 in the last week).

DO $$ DECLARE ts_start timestamp := '2019-03-20 00:00:00'; ts_end timestamp := '2019-07-02 01:12:13'; i numeric := (select to_char(age(ts_end, ts_start),'MM')); interval_value varchar := i || ' month'; xyz date := (select date_trunc('month',ts_start::date) + interval_value::text::interval); BEGIN RAISE EXCEPTION '%', xyz; END $$;
ERROR: 2019-06-01 CONTEXT: PL/pgSQL function inline_code_block line 9 at RAISE
 hidden batch(es)


DO $$ DECLARE ts_start timestamp := '2019-03-20 00:00:00'; ts_end timestamp := '2019-07-02 01:12:13'; xyz date := date_trunc('month', ts_start) -- timestamp! + date_trunc('month', age(ts_end, ts_start)); BEGIN RAISE EXCEPTION '%', xyz; END $$;
ERROR: 2019-06-01 CONTEXT: PL/pgSQL function inline_code_block line 8 at RAISE
 hidden batch(es)