I start with =today() in the first cell which works fine. And then use =A2-IF(WEEKDAY(A2)<5,3,1) which I found on the internet but is giving me wrong dates.
getting 19 days:
=INDEX(TEXT(SEQUENCE(19, 1, TODAY()-18), "dd/mm/yyyy"))
excluding weekends from those 19 days:
=INDEX(QUERY(TEXT(SEQUENCE(19, 1, TODAY()-18), {"dd/mm/yyyy", "ddd"}),
"where not Col2 matches 'Sat|Sun'"),, 1)
adding a list of holidays which should be excluded too:
=INDEX(QUERY(TEXT(SEQUENCE(19, 1, TODAY()-18), {"dd/mm/yyyy", "ddd"}),
"where not Col2 matches 'Sat|Sun'
and not Col1 matches '"&TEXTJOIN("|", 1, D2:D)&"'"),, 1)
getting 19 entries after excluding weekends and holidays:
=INDEX(SORT(QUERY(TEXT(SEQUENCE(50, 1, TODAY()-49),
{"dd/mm/yyyy", "ddd", "@"}),
"where not Col2 matches 'Sat|Sun'
and not Col1 matches '"&TEXTJOIN("|", 1, D2:D)&"'
order by Col3 desc
limit 19"), 3, 1),, 1)
if you for some reason need valid dates use:
=INDEX(TO_DATE(1*SORT(QUERY(TEXT(SEQUENCE(50, 1, TODAY()-49),
{"dd/mm/yyy", "ddd", "@"}),
"where not Col2 matches 'Sat|Sun'
and not Col1 matches '"&TEXTJOIN("|", 1, D2:D)&"'
order by Col3 desc
limit 19"), 3, 1)),, 1)