Purchasing the night before your trip works. That's because trip insurance goes into effect the day after you purchase it. So if it's midnight on the day of your departure, it's too late to buy comprehensive travel insurance. Anytime before that works!