Get sweating, y'all!

Woman Exercising
Credit: Peopleimages/Getty Images

Looking for the key to happiness? You might want to start by breaking a sweat.

According to a study from researchers at Yale and Oxford, when it comes to mental health, exercise may be more important than money.

In the study, published in The Lancet, scientists collected data about the physical behavior and mental health of more than 1.2 million Americans. Each participant was presented with the following question: "How many times have you felt mentally unwell in the past 30 days, for example, due to stress, depression, or emotional problems?"

Participants were also asked about their income and activity level. They were able to choose from 75 types of physical activity, from lawncare and housework to weight lifting and running, Business Insider reports.

Scientists discovered that those who exercised regularly reported feeling bad for about 35 days a year. Non-active participants, on the other hand, averaged 18 more bad days a year. They also found that people who are physically active feel just as good as those who avoid physical activity but earn $25,000 more a year.

WATCH: The Countless Ways Knitting Can Improve Your Health and Happiness

But exercising too much can have the reverse effect on happiness. According to the study, physical activity only improves mental well-being within a certain time frame: three to five training sessions per week, each lasting around 45 minutes, is ideal.

Interestingly, the mental health of those participants who exercised for longer than three hours a day reported poorer moods than of those who were less physically active.

The largest mood boosts were associated with popular team sports and cycling, as well as aerobic and gym activities.