Are you doing this in script if so, this works as From Date we need to go back 180 Days that means we need to calculate how many dates week has. So, 180 / 7 = 25. If Today() it returns 39 - 25 = 13. And output returns here 2017/13 so from this we are picking Right side of 2 strings and it should return 13 as always..
Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)