That's because dates are technically stored as numbers ,a value of 0 is 1900-01-01, 1 is 1900-01-02. Having a value of 20170516 would be 20,170,516 days after 1900-01-01. Considering that there's 365.25 days in a year... That's (approximately) 55,233 years, 313 days. So, entering an integer value of 20170516 is like entering the date 57133-11-10. That's a LONG time from now ;).
So your example above, using integers, would really be:
DATEDIFF(DAY, 42869, 42902)
(try running that, it works, and gives the results 33)
If you're storing dates, store them as dates, simply put. It makes things a lot easier. 🙂
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.