The team found that people who slept for longer or shorter durations had poorer cognitive performance and mental health.
Seven hours of consistent sleep is ideal for people in their middle age and upward, research from the University of Cambridge suggests.
Scientists examined data from nearly 500,000 adults between the ages of 38 and 73 for the study.
The team found that seven hours per night was the optimal amount for cognitive performance and mental health. It also helps keep the brain healthy by removing waste products, according to the study.
Researches say that lack of sleep may also hamper the brain's ability to rid itself of toxins.
People who experience anxiety and depression slept for longer or shorter durations, according to researchers.
Professor Barbara Sahakian from the Department of Psychiatry at the University of Cambridge is one of the study's authors, and says that getting a good night's sleep is not only important at any age, but particularly important as people age.
"Finding ways to improve sleep for older people could be crucial to helping them maintain good mental health and wellbeing and avoiding cognitive decline, particularly for patients with psychiatric disorders and dementias," Sahakian said.