Gandalf and Bilbo stayed at Beorn's home for one week on their way back to Hobbiton
Until the end of The Return of the King, when he went to the Undying Lands with the elves and Frodo.
They did not take Gandalf's and Beorn's advice to STAY ON THE PATH while traveling through Mirkwood.
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 enter in pairs because Gandalf tells them to do it. They don't want to go in all at once, so Beorn will think they were trying to kill him The dwarves must enter Beorn's house in pairs so that, as Gandalf tells their tale to Beorn, each entrance does not seem very imposing and Beorn's interest in the story is built up. Then the group will be able to stay with Beorn.
17 days
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.
In Chapter 10 of "The Hobbit," titled "A Warm Welcome," Bilbo and the dwarves arrive at Lake-town (Esgaroth) after their journey through the Mirkwood. The townspeople greet them warmly, as they are excited about the prospect of the dwarves reclaiming their treasure from the lonely mountain. During their stay, Bilbo is recognized as the burglar and gains confidence, while the Master of Lake-town sees the potential for profit in their quest. This chapter highlights themes of hospitality and the growing anticipation of the adventure ahead.
Gandalf proves to be a very good manipulator when talking to Beorn because of how he brings the Dwarves in at very high points in the story. He does this so Beorn would stay interested in the story. I hope this answered your question:)
In "The Hobbit," the Company of Dwarves, along with Bilbo and Gandalf, stays in Esgaroth (Lake-town) for a short period, roughly a few days. Their arrival is greeted with hospitality as they prepare for their journey to the Lonely Mountain. During this time, they gather supplies and rest before continuing on their quest to reclaim the Dwarven homeland from Smaug the dragon.
Bilbo rejoins the dwarves after escaping the goblin cave. They is a recap the flight from the goblins in the dark and Bilbo makes up a bit of a story about what happened, keeping the ring a secret. While putting distance between them and the goblins' mountain stronghold they are discovered by a pack of wargs and climb into the trees to escape. The Goblins join the wargs and start to burn Gandalf, the dwarves and the hobbit out of the trees. The giant eagles swoop down from the sky and pluck them from the tree tops and take them to their aerie. After Gandalf talks with the eagles they cook food and eat and then fall asleep.
Stay with them at the camp rather than return to the dwarves.
Gandalf is worried that Smaug may become an ally to the newly returned Sauron.