It is the perfect excuse to indulge in a daytime cup of coffee and an evening glass of wine - both together could make you feel less sleep-deprived than having either on its own.
It is well known that coffee during the day can make it harder to fall asleep at night.
But a study suggests also having an alcoholic drink before bed could help to sleep longer, offsetting some of the effect of the caffeine.
Meanwhile an evening tipple can lead to poor-quality slumber, but coffee could make this easier to deal with, by boosting alertness.
The best night's sleep will always be achieved by avoiding both coffee and alcohol.
But, for those who cannot resist, the new research suggests a daytime coffee and an evening drink could help balance each other out.
The findings come from a six-week study of 17 people, which discovered every daily small cup of coffee, or a similar caffeinated drink, reduced the average amount of sleep someone got by around 10 minutes a day - or an hour a week.
However, for every cup, plus a standard alcoholic drink that someone had per day, the results suggest they would see a sleep reduction of approximately only five minutes a day, or half an hour a week.
An alcoholic drink, which tends to increase sleepiness, could therefore cancel out some of the effect of a coffee earlier in the day.
The study found every extra standard alcoholic drink a day, like a small glass of wine or half a pint of beer, caused a more restless night's sleep, based on people's rating of how well they slept from zero to 100.
But if they also had caffeine that day, people ranked their sleep quality less poorly.
Researchers believe coffee can help to mask the daytime drowsiness caused by alcohol's effect on sleep.
Frank Song, who led the study from the University of Washington, said: 'We see evidence to suggest that people drink coffee and alcohol in an effort to "balance" their sleep.
'Indeed, having alcohol after coffee may give you an easier time falling asleep, and coffee may make people feel less drowsy if they drink alcohol later in the day.
'However they should be aware they probably are still getting worse quality sleep, and both alcohol and caffeine are best avoided overall.'
The study, published in the journal PLOS One, looked at financial traders, as an example of busy, working people who often rely on both caffeine and alcohol.
Every day for six weeks the male volunteers completed a daily survey including how long and well they slept.
The apparently positive effect of alcohol being a sedative, which causes drowsiness, is that people lost less sleep after drinking it along with caffeine, rather than having caffeine alone.
The more negative effect is that alcohol suppresses important 'rapid-eye-movement' (REM) sleep at the start of the night, making sleep poorer in quality after a drink.
But, although people ranked their night's sleep three points more poorly on the 100-point scale after each glass of alcohol, this effect was slightly reduced for every small cup of a caffeinated drink they had in the same day.
Caffeine, which stays in the body for hours, could mask the drowsiness someone feels after a poor night's sleep following a nightcap.
The study only looked at the sleep durations and quality people reported, rather than using sleep trackers, so more research is needed.
Researchers also did not track exactly when in the day people consumed caffeine or alcohol.
But they conclude that the results may help to explain why people 'self-medicate' with both alcohol and coffee to feel less tired.