You kind of have two questions in one - When can I call Clearance Delivery to get my clearance? and How long is that clearance good for?
Casey covered the first part - the local controllers will usually have your clearance 30 minutes before your scheduled departure.
Sometimes you can get this information a little earlier yourself - the new Flight Service tools like 1800WXBRIEF.com can give you expected clearance and flight plan routing information based on what you filed, if the ATC computer already knows what it's going to do with your flight. Here's a few words about it from the Foreflight folks, and you can do the same thing yourself with the Lockheed-Martin tools with a few more manual steps.
You still need to talk to the controllers but if you know what they're going to say it makes that conversation faster!
The second part can go one of two ways: The point of the "void time" is that the ATC system is reserving a spot in the system for you up until that specific time. After that ATC is going to let other aircraft use the airspace they were holding for you (they may allow someone to make an instrument approach to the airport you're leaving from, for example).
This is used a lot for non-towered fields where you have no local controller to talk to.
Clearances from Clearance Delivery at a towered field can include a void time, but they generally don't because they assume you're in the plane and ready to go at or around the time you call in, and you have local controllers to talk to if you have a problem during the run-up or something which delays your departure. Basically the clearance is good until someone tells you otherwise in that situation.
The tool that gets used at towered fields more often is
Hold for release: You've been issued a clearance, but you can't execute it until the tower has coordinated you a spot in the airspace. This is generally more efficient than reserving airspace with a clearance and void time when there are controllers to talk to, and if everything is working well your release should be ready right around the time you're ready to take the runway for departure.