Happy to clarify.
So, in general, I have a tendency to stay up late. Normally though, I get in bed early enough to futz around long enough to fall asleep to get 7-8 hours of sleep, which is adequate, although not ideal.
But every once in a while (and OFTEN around transitional periods such as going on holidays, changing a work schedule, or Daylight Saving Time) it’ll keep drifting later, 15 minutes, then 30, then 45, which leads to sleep anxiety (I can’t fall asleep!) which makes the problems worse.
So after years of this, I started using OTC sleep aids as soon as the problem has gone on for more than 3 days (so generally when I’m at risk of losing a full hour of sleep). Normally, two days of taking the OTC sleep aid and getting a solid 8+ hours of sleep not only resets the sleep schedule, but having been rested, kills the sleep anxiety.
On the other hand, I have an IRL friend who has SERIOUS anxiety issues, which make me look like a frikkin’ rock by comparison. They too used OTC (at my advice), but as they got older, the OTC options were less efficacious, or the anxiety got worse. So they have prescription sleep and anxiety meds. Which, in their words, works like a light switch. No delays futzing around after taking one - you have X minutes and then you better be in bed. And he says when he takes them, it’s the most restful sleep he has ever had, waking up fully rested and with none of the grogginess / medicine head I associate with doxxy and other OTC options.
Of course, it’s prescription only and can be habit forming, so, different risks.
As for it working on an intermittent basis, it almost certainly depends on why your sleeping patterns changed. It could be something as simple as your mattress slowly giving out and not being able to get fully comfy again when you’re no longer as tired. It could be a medical issue. It could be something as (speaking from experience this time) a bedside fan starting to fail and spinning up/down at semi-regular intervals startling you awake.
Not being able to fall back to sleep, especially when you are as tired as described is another issue to identify. For me, it was a combination of anxiety (I only have x hours to fall back asleep before I have to get up for work) and the brain spinning up to being fully awake too quickly - which is still a problem for me.
One last thing that was suggested back when I was figuring out options was to (assuming your residence allows) try to fall asleep in a different bed, in a different room, and see if it made a difference. This is why I mention things like bed fans, sleep partners, and mattress quality. You can eliminate possible causes, but of course, you’re exposed to others.
OTC options are quick, reasonably cheap, and easy. If they work as described they’re great for a short term use. But if it is required all the time, likely something else is going on which ideally should be addressed. If nothing else, because while the cost is minimal, there’s always a risk that you’ll have a harder time getting up and responding if there’s a nighttime emergency.