If I have ever made any valuable discoveries, it has been owing more to patient attention, than to any other talent. (Isaac Newton)
Any given problem generally requires months of effort in order to make satisfactory progress. While it is possible for routine or unexpectedly easy problems to fall within weeks, this is the exception rather than the rule.Thus it is not uncommon for months to pass with no visible progress; however by patiently eliminating fruitless avenues of attack, you are setting things up so that when the breakthrough does come, one can conclude the problem in relatively short order. (But be sceptical of any breakthrough which was “too easy” and mysteriously failed to address the key difficulty.)
In some cases, you (or the mathematical field in general) are simply not ready to tackle the problem yet; in this case, setting it aside (but not forgetting it entirely), building up some skill on other related problems, and returning back to the original problem in a couple years is often the optimal strategy (particularly if your formal mathematical education is still not complete). This is particularly likely to be the case for any really famous problem.
Incidentally, most problems are solved primarily by this sort of patient, thoughtful attack; there are remarkably few “Eureka!” moments in this business, and don’t be discouraged if they don’t magically appear for you (they certainly don’t for me).
Here is a short poster by Ira Glass making some related points, in the context of creative work.