clear markdown compare help best fiddles feedback dbanow.uk
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. 2555458 fiddles created (37473 in the last week).

create table t (dt timestamp); insert into t values ('20200110'),('20200203'),('20200715');
3 rows affected
 hidden batch(es)


select generate_series(date_trunc('month', dt)::date, (date_trunc('month', dt)::date + interval '1 month - 1 day')::date, interval '1 day') dts from t
dts
2020-01-01 00:00:00+00
2020-01-02 00:00:00+00
2020-01-03 00:00:00+00
2020-01-04 00:00:00+00
2020-01-05 00:00:00+00
2020-01-06 00:00:00+00
2020-01-07 00:00:00+00
2020-01-08 00:00:00+00
2020-01-09 00:00:00+00
2020-01-10 00:00:00+00
2020-01-11 00:00:00+00
2020-01-12 00:00:00+00
2020-01-13 00:00:00+00
2020-01-14 00:00:00+00
2020-01-15 00:00:00+00
2020-01-16 00:00:00+00
2020-01-17 00:00:00+00
2020-01-18 00:00:00+00
2020-01-19 00:00:00+00
2020-01-20 00:00:00+00
2020-01-21 00:00:00+00
2020-01-22 00:00:00+00
2020-01-23 00:00:00+00
2020-01-24 00:00:00+00
2020-01-25 00:00:00+00
2020-01-26 00:00:00+00
2020-01-27 00:00:00+00
2020-01-28 00:00:00+00
2020-01-29 00:00:00+00
2020-01-30 00:00:00+00
2020-01-31 00:00:00+00
2020-02-01 00:00:00+00
2020-02-02 00:00:00+00
2020-02-03 00:00:00+00
2020-02-04 00:00:00+00
2020-02-05 00:00:00+00
2020-02-06 00:00:00+00
2020-02-07 00:00:00+00
2020-02-08 00:00:00+00
2020-02-09 00:00:00+00
2020-02-10 00:00:00+00
2020-02-11 00:00:00+00
2020-02-12 00:00:00+00
2020-02-13 00:00:00+00
2020-02-14 00:00:00+00
2020-02-15 00:00:00+00
2020-02-16 00:00:00+00
2020-02-17 00:00:00+00
2020-02-18 00:00:00+00
2020-02-19 00:00:00+00
2020-02-20 00:00:00+00
2020-02-21 00:00:00+00
2020-02-22 00:00:00+00
2020-02-23 00:00:00+00
2020-02-24 00:00:00+00
2020-02-25 00:00:00+00
2020-02-26 00:00:00+00
2020-02-27 00:00:00+00
2020-02-28 00:00:00+00
2020-02-29 00:00:00+00
2020-07-01 00:00:00+01
2020-07-02 00:00:00+01
2020-07-03 00:00:00+01
2020-07-04 00:00:00+01
2020-07-05 00:00:00+01
2020-07-06 00:00:00+01
2020-07-07 00:00:00+01
2020-07-08 00:00:00+01
2020-07-09 00:00:00+01
2020-07-10 00:00:00+01
2020-07-11 00:00:00+01
2020-07-12 00:00:00+01
2020-07-13 00:00:00+01
2020-07-14 00:00:00+01
2020-07-15 00:00:00+01
2020-07-16 00:00:00+01
2020-07-17 00:00:00+01
2020-07-18 00:00:00+01
2020-07-19 00:00:00+01
2020-07-20 00:00:00+01
2020-07-21 00:00:00+01
2020-07-22 00:00:00+01
2020-07-23 00:00:00+01
2020-07-24 00:00:00+01
2020-07-25 00:00:00+01
2020-07-26 00:00:00+01
2020-07-27 00:00:00+01
2020-07-28 00:00:00+01
2020-07-29 00:00:00+01
2020-07-30 00:00:00+01
2020-07-31 00:00:00+01
 hidden batch(es)


select date_part('month', dts) mt, count(*) as wd from (select generate_series(date_trunc('month', dt)::date, (date_trunc('month', dt)::date + interval '1 month - 1 day')::date, interval '1 day') dts from t) t2 where date_part('dow', dts) <> 6 group by date_part('month', dts);
mt wd
7 27
1 27
2 24
 hidden batch(es)