You can use a "trick" called dimensional analysis. It lets you solve many problems, including this one. You can start off putting down what you know as numerator / denominator fractions, so

(5 days / 40 hats) is one expression. It says that in 5 days you get 40 hats.

However, that is not our answer, since we want "days" as the only unit left. We need to multiply that fraction by hats so only "days" are left.

We know you want 680 hats, so

680 hats X (5 days / 40 hats) = days

The hats units cancel, leaving days.

Final answer is 680 X (5 / 40) = 85 days

You can double check the answer another way. 40 hats every 5 days would be an average of 40/5 = 8 hats per day. You would then take the total number of hats (680) and divide that by the average number of hats you get per day. 680/8 = 85 days, which is the same answer.

I like the dimensional analysis way better, since you almost don't have to think to get words problems like this correct. It is very powerful, but takes some time to get used to it.