SELECT ((DATEDIFF('2014-10-25', '2014-10-15')) -
((WEEK('2014-10-25') - WEEK('2014-10-15')) * 2) -
(case when weekday('2014-10-25') = 5 then 1 else 0 end) -
(case when weekday('2014-10-15') = 4 then 1 else 0 end)) as DifD
// Total difference
SELECT ((DATEDIFF('2014-10-25', '2014-10-15'))
// calendar week(s) ---> not including the year
WEEK('2022-01-02') // = 1
WEEK('2021-12-30') // = 52
// get weekday, where 0 is monday and 6 is sunday
case when weekday('2022-01-02') = 4 // (or 5) subtract 1
If you want this to work on different years, like your example above u have to add 52 weeks for every year difference.
a working example would be:
SELECT ((DATEDIFF('2022-01-02', '2021-12-30'))+1 - ((WEEK('2022-01-02') - WEEK('2021-12-30') + 52) * 2) - (case when weekday('2022-01-02') = 5 then 1 else 0 end) - (case when weekday('2021-12-30') = 4 then 1 else 0 end)) as DifD