select c.bdate,
case
when length(c.dot_three)=4 and (c.dot_one::int between 13 and 31) and c.dot_two::int<=12 then concat(c.dot_three,'-',c.dot_two,'-',c.dot_one)
when length(c.dot_three)=4 and c.dot_two::int<=12 and c.dot_one::int<=12 then concat(c.dot_three,'-',c.dot_two,'-',c.dot_one)
when length(c.dot_three)=4 and (c.dot_two::int between 13 and 31) and c.dot_one::int<=12 then concat(c.dot_three,'-',c.dot_one,'-',c.dot_two)
when length(c.dot_one)=4 and (c.dot_three::int between 13 and 31) and c.dot_two::int<=12 then concat(c.dot_one,'-',c.dot_two,'-',c.dot_three)
when length(c.dot_one)=4 and c.dot_two::int<=12 and c.dot_one::int<=12 then concat(c.dot_one,'-',c.dot_two,'-',c.dot_three)
when length(c.dot_one)=4 and (c.dot_two::int between 13 and 31) and c.dot_three::int<=12 then concat(c.dot_one,'-',c.dot_three,'-',c.dot_two)
when length(c.slash_three)=4 and (c.slash_one::int between 13 and 31) and c.slash_two::int<=12 then concat(c.slash_three,'-',c.slash_two,'-',c.slash_one)
when length(c.slash_three)=4 and c.slash_two::int<=12 and c.slash_one::int<=12 then concat(c.slash_three,'-',c.slash_two,'-',c.slash_one)
when length(c.slash_three)=4 and (c.slash_two::int between 13 and 31) and c.slash_one::int<=12 then concat(c.slash_three,'-',c.slash_one,'-',c.slash_two)
when length(c.slash_one)=4 and (c.slash_three::int between 13 and 31) and c.slash_two::int<=12 then concat(c.slash_one,'-',c.slash_two,'-',c.slash_three)
when length(c.slash_one)=4 and c.slash_two::int<=12 and c.slash_three::int<=12 then concat(c.slash_one,'-',c.slash_two,'-',c.slash_three)
when length(c.slash_one)=4 and (c.slash_two::int between 13 and 31) and c.slash_three::int<=12 then concat(c.slash_one,'-',c.slash_three,'-',c.slash_two)
else ''
end as gdate
from (
select t.bdate,split_part(bdate,'.',1) as dot_one, split_part(bdate::text, '.',2) as dot_two,
split_part(bdate::text, '.',3) as dot_three,
split_part(bdate,'/',1) as slash_one, split_part(bdate::text, '/',2) as slash_two,
split_part(bdate::text, '/',3) as slash_three
from
(SELECT unnest(array['31.08.2014','16.09.2014','13.12.2015','10/9/2018','4/4/2019','2022/4/4','3/2/2018','27/8/2019','15/2/2019','26/11/2019']) as bdate)t
)c
WHERE date >= date '2022-01-01' AND date < date '2022-03-01'
where date >= ? and date < ? + interval '2 month'
(assuming that?
is e.g. 2022-02-01)