Obama: Zero. Zip. Zilch.
Obama has never served or "attempted" to serve (Clinton), in any branch of the military, although he does sit on the U.S. Senate Committee on Veterans Affairs. It bears mentioning that he’s too young to have faced the draft during the Vietnam War.
McCain: In the Navy…
John McCain entered the United States Naval Academy in 1954 and managed to have a distinguished military career even though he was fifth from the bottom of his graduating class. An aviator, he once took down power lines during a low-flying jaunt in Spain in the early sixties. He barely escaped a fire on the USS Forrestal in 1967, when a missile errantly hit the fuel tank of his A-4E Skyhawk and killed 134 of his shipmates. On McCain’s 23rd bombing mission in Vietnam, his plane was shot down over Truc Bach Lake on October 26, 1967. A POW for more than five years, McCain refused preferential treatment and an early release offered because of his father’s military status. After returning to the U.S., McCain underwent extensive physical therapy in order to return to flying condition. He took command of Attack Squadron 174 in 1976, the same year he was appointed Navy liaison to the Senate. McCain's physical injuries ensured that his career would likely stall there. He retired from the Navy in 1981, the recipient of the Silver Star, Bronze Star, Legion of Merit, Purple Heart, and the Distinguished Flying Cross.