convert YYYYMM to Date

Hi,

I am trying to convert a date in yearmonth format to regular date . The day will be always first of the month 

 

that is input is  201809(text) output is 01/09/2018(date )

 

load(
local!FDYMYear:
          left(
            ri!yearmonth,
            4
          )
        ,
        local!FDYMMonth: if(
          len(
            ri!yearmonth
          ) = 5,
        
            right(
              ri!yearmonth,
              1
            ),
            right(
              ri!yearmonth,
              2
            )
         
        ),

   todate(local!FDYMMonth&"/"&"01"&"/"&local!FDYMYear)   
        )

 

i am using the above rule . it works fine for all the dates except if the month is October . 

 

it is not working for 201810 ,201710 . it works for all the other yearmonths 

  Discussion posts and replies are publicly visible