"How long can I keep an open bottle of wine and it still be good? For how long will it be drinkable, and for how long will it be good for cooking?"
Opened wine doesn't tend to hang around very long in my house, so I asked Richard Vayda, Director of the Institute of Culinary Education's Wine and Beverage Studies, for advice. He suggests using a simple vacuum wine pump, which is a rubber stopper and a pump apparatus, to keep some wines drinkable for up to a week. (I use an inexpensive Vacu Vin). Mr. Vayda cautions that the amount of time an opened, vacuum-sealed wine remains drinkable varies by the characteristics of the wine: heavier wines last longer than lighter ones.
Keep vacuum sealed wine refrigerated–even if it is red and meant to be drunk at room temperature. You can let it warm up a bit just before serving.
You have a little more leeway when cooking with wine, depending on the role of the wine in your dish. Often, when cooking with wine, you boil it down, which intensifies the flavor. That's great, because it helps offset theloss of flavor that occurs when wine is opened. Wines that had big, robust flavor to begin may still good for cooking 10-14 days later, while lighter wines may lose their raison d'être after about a week.
For more information on using wine in recipes, see 7 Ways with Wine.