Shopping at a store that has shucked corn on racks out of cooler.
There's no definite answer to that- sugars in the corn start converting to starch as soon as it's picked, and it will lose sweetness over time, but spoilage isn't a big problem, just flavor loss. The traditional wisdom is that corn should be cooked as soon as possible after picking (they tell you to run from the field to the kitchen and to have your boiling water ready when you get there). Modern varieties-- the now ubiquitous white corn and newer "supersweet" yellows, hold their sugar much better than older sweet corn varieties.
They generally recommend that you store fresh corn in the husk, refrigerated, for up to a week. But people who grow corn for sale often will pick it a day or so before it gets to the buyer, and it's not often refrigerated. The conversion of the sugars to starch begins as soon as the ear is removed from the stalk, and chilling just buys a bit of time- but most modern varieties are bred to be extra sugary, so the conversion takes a bit longer before you would notice it in the taste. All corn also loses moisture, and naturally dries to finish developing the individual kernels, as they are the seeds of the plant. The husk shows the drying process soonest, which is one reason stores will remove the outer husks and package it in plastic. They lead you to think it is for your convenience, and I suppose it is- but the real reason is to make it more easily and quickly sold. It would be safe as long as you don't see visible signs of spoilage- mold, etc. It won't taste as good as the stuff you shuck at home yourself, but it would be safe to cook and eat. Though for my money, I skip the shucked stuff. It's shucked for a reason, and that reason is not really for your convenience, but because it's old stock that they need and want to move.