17 days
Until the end of The Return of the King, when he went to the Undying Lands with the elves and Frodo.
Gandalf and Bilbo stayed at Beorn's home for one week on their way back to Hobbiton
Bilbo travels with Gandalf and Beorn to the long north pass around Mirkwood. Then they stay at Beorn's house for the winter. Then Gandalf and Bilbo travel to Rivendell, there Bilbo gets medical attention. Then Gandalf and Bilbo travel the long way to the Hobbit lands.
They don't stay anywhere for 15 days. They are in Rivendell for 17 days, and in Lake-town for 20. They only stayed a short time with Beorn.
The coincidence that helps the dwarves during their stay at Rivendell is when the moon comes out while Elrond is looking at the map. It has moon runes on it with extra information. This helps them along the journey to get to the treasure.
They have several stops where they get out of the weather and get some sleep. They go to Rivendell once. They stay at Beorn's house. They stay in a cave but that turns out to be a bad idea because they get kidnapped by goblins.
They did not take Gandalf's and Beorn's advice to STAY ON THE PATH while traveling through Mirkwood.
Gandalf is worried that Smaug may become an ally to the newly returned Sauron.
Both Beorn and Gandalf warned them to stay on the path.
It does not give a precise length of time on their way out, but looks like 17 days based on the conversations. They left on Midsummer's Day. On the way back home with Gandalf he spends a week there.
As long as they stay babies is how long they stay babies.
how long would you stay with us how long would you stay with us