Whenever I get stuck on a problem, I try to clear my head. That usually involves tackling another task, getting some fresh air, or just going home.
I noticed that going home early and tackling the problem early the next morning helps more than the 2-3 hours I spent with no success.