It is about one hour by car.
The closest part to the Airport is the Mutianyu Great Wall and it should take no more than an hour each way to get there, so you do have time to visit, provided you take a car directly to the Wall, have the driver wait, and then return you to the airport. If your outbound flight is international and your bags are already checked through and you have your boarding pass, then you'll need to be back at the terminal about 1.5 hours before departure, in order to have time to deal with immigration and security. This leaves you about 4 to 4.5 useable hours, minus 2 hours total travel, or 2 to 2.5 hours on the Wall. That's actually pretty decent.
If you are a Mandarin speaker, you can probably just wait until you get to the airport and engage a cab for a flat fee (negotiated/non-metered)--for time and distance, I'd say about RMB 300-350 for the journey is plenty. If you are not a Mandarin speaker, then it might be best to engage in advance a car company to meet-and-greet and take you out there directly and back. Likely it will be more in the RMB 500-ish range though. Entry fee and cable car fee (if you don't want to hike up to top) are extra.Edited: 18 February 2011, 16:00
1hr to Mutianyu NOT Badaling (which is further away).
To clarify #3, when you arrive in PEK for a connection only, you don't get a "visa out of the airport" you will get a transit stamp (which is not a visa) which is good for 24 hours, by which time you are expected to be on a departing international flight out of PEK. You can leave the airport. This stamp is NOT a regular visa and it is NOT a transit visa, it is a visa-free transit stamp and does not look like a stamp given to a person officially entering China with a visa. Let's not mix up all these various terms.Edited: 28 February 2011, 04:27
thanks for your explaination, KV.
#5. I will be having a layover of 7 hours in July and want to visit the wall, where do I get such a visa-free transit stamp?
When I called the Chinese Embassy here in Denmark, they said nothing about such a stamp, just that it was possible with a visa which would cost me about $300 for 2 visa's
It is one hour and 60 KM.
But you can see around just for a few hrs or not I've plenty of time layout in the airport 9.00 hrs to comeback to USA.