Try going to sleep when the sun is rising, and staying asleep during the brightest hours of the day. It’s never easy. The odd sleep schedules that come with shift work go against everything we learned at an early age. Turning your sleep schedule topsy-turvy is a shock to the system that often leads to insomnia and chronic fatigue.

The same can’t be said for switching from shift work to regular daytime hours, a new study reports. Swedish researchers examined the transition hardships associated with shift work.

The study involved more than 3,600 participants who answered questionnaires about work hours, sleep and work environment at the start and end of a five-year period.

Results show the participants had the most sleeping problems upon entering shift work. Many reported falling asleep on the job and having difficulty getting to sleep after work.

Switching back to daytime hours had the opposite effect. The risk of work fatigue and insomnia significantly diminished after leaving shift work.

The findings were adjusted for various factors including work demands, physical workload, and familial status.

Not all shift work schedules are equally difficult a previous study suggests. Jobs with start times between 8 p.m. and 12 a.m. tend to limit sleep and harm performance at work.

Caffeine may help offset fatigue and limit mistakes at work. Make sure to limit consumption to the first couple of hours of work so you don’t have problems getting to sleep later.