The question was asked in one scientific study recently and they provided an answer, one that I wasn't expecting. For as long as I can remember, I've always though coffee will 'keep me up at night', and while it does affect your alertness, it wont keep you up all night.
It was discovered that if you were to consume two single shot espresso's, upto three hours from when you would go to bed, your sleep hormones van be delayed by up to 40 minutes.
I am fortunate in that I can enjoy a coffee right before bed and I have never felt an effect.
What about you?