select trunc(to_date(substr(20180607,1,6),'YYYYMM'), 'MM') as month_first
,add_months(trunc(to_date(substr(20180607,1,6),'YYYYMM') ,'MM'),1) as month_last from dual;
V_START_M :=trunc(to_date(substr(IN_DATE,1,6),'YYYYMM'), 'MM');--起始日期 月初
V_END_M :=add_months(trunc(to_date(substr(IN_DATE,1,6),'YYYYMM') ,'MM'),1);--截止日期 下月初
select * from t1 WHERE
--AND SUBSTR(T1.year,1,6) = substr(in_date,1,6) --限制本月 :当year
AND T1.year>=V_START_M
AND T1.year<V_END_M