Is your afternoon coffee keeping you up?
Move your last caffeinated drink earlier for a week and see what changes.

Count what’s in the cup
For a few ordinary days, note when you have coffee, tea, energy drinks, or caffeinated pre-workout, and estimate the amount when you can. A large café coffee and a mug of tea are both one drink on paper. The caffeine content can be quite different. Each morning, note how long falling asleep seemed to take and how rested you feel.
Move the usual order
For seven days, have your last caffeinated drink earlier. If you usually go to bed at 11 p.m., one experiment is to move a 4 p.m. coffee to 2 p.m. Keep the serving size and your bedtime and wake time roughly steady so you’re comparing similar days. If you regularly use caffeine and want to reduce the amount as well, do it gradually.
The dose matters
In one small crossover trial involving 23 men, a single 400 mg dose affected some measures of sleep when taken up to 12 hours before bedtime. The same study found no statistically significant effect at the tested times for 100 mg. Your response can differ. An earlier cutoff gives you one variable to test, especially if your usual serving is large.
Compare several mornings
Did you tend to fall asleep more easily, wake less, or feel more rested? Look at the whole week. A late shift, travel, or a night out can make a single morning hard to interpret. If the earlier drink seems to help and still fits your day, stick with it.