select
aa,
to_char(aa,'HH24:mi:ss'),
case when to_char(aa,'HH24:mi:ss')>='00:00:00' and to_char(aa,'HH24:mi:ss')<= '08:15:00'
then to_char(add_days(aa,-1),'yyyy-MM-dd')
else to_char(aa,'yyyy-MM-dd')
end as aa_new
from (
select '2022-01-03 08:10:12' aa from dummy
union all
select '2022-01-03 14:10:12' aa from dummy
union all
select '2022-01-09 08:10:12' aa from dummy
union all
select '2022-01-09 08:15:12' aa from dummy
union all
select '2022-01-10 09:10:12' aa from dummy
)