Prince Philip, who died aged 99 on Friday, spent a month in hospital before he was discharged, and was at Windsor Castle for just over three weeks before his death.
Buckingham Palace did not specify a cause when announcing his death on Friday, but Philip, also known as the Duke of Edinburgh, had a history of heart trouble.
His health had deteriorated since being admitted to King Edward VII's Hospital in London on February 16 with an infection.
He walked into the hospital, but when he left on March 16 was in a wheelchair, the BBC reported. It had been his longest-ever hospital stay.
The illness he was admitted for appeared to be unrelated to COVID-19 — he and Queen Elizabeth II had been vaccinated against the virus in January.
After a week in hospital, Philip was "comfortable and responding to treatment," a spokesperson for the duke said. The official said he would remain there only as a precautionary measure.
However, he later worsened. On March 1 he was moved to a specialist cardiovascular hospital, St Bartholomew's, around 3 miles away.
Two days later he had had a "successful procedure," for a heart condition, Buckingham Palace confirmed. He was then returned to King Edward VII's Hospital to recuperate.
After his release in March, Philip's son Prince Charles said he was "thrilled" his father was out.
Philip was previously admitted to hospital with an unspecified pre-existing condition in December 2019, a visit that was described as having been planned in advance.
He had experienced heart problems for a number of years. In 2011 he had what the BBC referred to as a "significant health scare" when he received treatment for a blocked coronary artery after suffering chest pains.
He stepped down from official royal engagements in 2017, citing health reasons.