clear markdown feedback
clear markdown feedback
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 3364508 fiddles created (36226 in the last week).

create table bd (id int primary key, bday date);
 hidden batch(es)


insert into bd values (1, '20180102'),(2, '20180104'),(3, '20180106'),(4, '20180108'),(5, '20180110'),(6, '20180112');
6 rows affected
 hidden batch(es)


select * from bd;
id bday
1 2018-01-02
2 2018-01-04
3 2018-01-06
4 2018-01-08
5 2018-01-10
6 2018-01-12
 hidden batch(es)


-- adding four bussines days to 03/01/2018 select max(bday) as the_day from ( select * from bd where bday > '20180103' limit 4 ) bd;
the_day
2018-01-10
 hidden batch(es)


select bday from (select bday, row_number() over (order by bday) rn from bd where bday > '20180103') bd where rn = 4;
bday
2018-01-10
 hidden batch(es)


create or replace function add_bussines_day(bday date, num_days int) returns date as $fbd$ select max(bday) as the_day from (select * from bd where bday > $1 limit $2 ) bd; $fbd$ language sql;
 hidden batch(es)


select add_bussines_day('20180103', 4);
add_bussines_day
2018-01-10
 hidden batch(es)