How long would the average medieval ship remain at sea?

That would be dependant on the size of the vessel. Even today vessels are restricted to their time away from a port. In the past their time was dependant upon how much food they could carry. Today it is how much food and fuel can they carry.

In the 1400's (Columbus) they could stay at sea for months without restocking food. If they came ashore to reprovision water and food they could go for years such as whalers.

In the mideval times I dont think they stayed out for more than a few months due to food and water.