Set user variables from tables being queried in MySQL without locking
Your first function can be even simpler by noting that

SELECT 0 + DATE('2017-01-18 08:31:38'); -- 20170118


But that is not usable for arithmetic.  Note that this time next month, 20170218, would be "100 days" from now:  

For the second one, look into DATEDIFF().  (No need to convert from DATETIME to DATE.)

See also the TO_DAYS() and FROM_DAYS() functions.  Today is 736712 and would work with aritmetic.

I suspect that all of this will eliminate the need for dimDate, thereby solving your stated problem??  If not sufficient, please provide SHOW CREATE TABLE for each table involved; we need to see what indexes you currently have.