The prince, 92, will be seen in public for the first time after his operation when he visits the Royal Society of Edinburgh on August 12, the Buckingham Palace has announced.
He had an operation on his abdomen in June and spent 11 nights at a private London hospital.
The Palace said the Queen's husband was making "good progress" and "in good spirits".
Philip will present medals at the independent educational charity before joining the 87-year-old Queen at Balmoral, the BBC reported.
More From This Section
An exploratory operation was carried out under general anaesthetic the following day, after which he was said to be "progressing satisfactorily".
Philip was last seen in public on June 17 when he walked out of the hospital here and was driven to Windsor Castle.
He will travel to Edinburgh from the Queen's Sandringham estate in Norfolk, where he has been recuperating.
Prince Philip is an honorary fellow of the Royal Society of Edinburgh, which was established in 1783 for the advancement of "learning and useful knowledge".