Thats not how magnesium works. Take it in 2 to 3 separate doses throughout the day with the last being close to bedtime. You won't feel sleepy during the day and it definitely won't make you groggy ever, it's just not that potent.
also, take more than recommended not less as the guidelines are set by fiat minded people who know nothing.
Another thing, I take a combination of mag citrate and glycinate, with glycinate being the form that helps the most with sleep. I combine with glycine for added sleep benefits right before bed.
If you have the dough you can spring for the ultimate form of magnesium called threonate. It's the only form that has the ability to cross the blood brain barrier which supposedly increases the benefits greatly. I haven't tried it yet but it's on my list.