SQL generate_series, dayofweek(DOW), weekday, functions
SQL
https://www.codewars.com/kata/58241d05e7a162c5b100010f/train/sql
-- Replace with your code CREATE OR REPLACE FUNCTION weekdays(DATE,DATE) RETURNS INTEGER AS $func$ SELECT COUNT(*) FROM GENERATE_SERIES(LEAST($1,$2),GREATEST($1,$2),'1d') AS days WHERE EXTRACT(ISODOW FROM days) < 6 $func$ LANGUAGE sql;
6
5
5
4
4
4