Current month:
select
case
when dayofweek_iso (substr(current_date, 1,8)||'01') = 6
then substr(current_date, 1,8)||'03'
when dayofweek_iso (substr(current_date, 1,8)||'01') = 7
then substr(current_date, 1,8)||'02'
else substr(current_date, 1,8)||'01'
end
from sysibm.sysdummy1
Previous month:
select
case
when dayofweek_iso (substr(current_date - 1 month, 1,8)||'01') = 6
then substr(current_date - 1 month, 1,8)||'03'
when dayofweek_iso (substr(current_date - 1 month, 1,8)||'01') = 7
then substr(current_date - 1 month, 1,8)||'02'
else substr(current_date - 1 month, 1,8)||'01'
end
from sysibm.sysdummy1