Wow!
I stopped really searching where the documentation said: "Casting expressions cannot be nested".
This is my result based upon what you showed:
cast( substring( cast(div(valid_to,1000000) as abap.char( 20 ) ), 1, 8) as abap.dats) as valid_to,
And it works!
Thanks a lot.
Kris