If we are talking "real world" times, the answer (obviously) depends on the scale and location of the damage. Superficial damage (non-essential structure) could be patched up in hours or a few days. damage to small to medium sized key equipment would push that out to days or a few weeks, and damag involving large bits of kit (especially alignment critical equipment such as fire control equipment) could stretch out to months if done properly.
Damage involving primary and secodary structure (decks, bulkheads and hull plating) couldbe patched in a few days and repaired in a few weeks if above the waterline. Significant underwater damage would requirea docking and could take months to repair.
Ultimately though, like many things, the question is a maritime equialent of "how long is a piece of string". There are other variables involved. For example,how efective do you want the repairs to be? A full repair, or just enough to get the ship back to sea? What is the priority of that particular ship, and so what degree of resources do you want to throw at it as opposed to other ships that you have to repair?
And another aspect to consider is that, sometimes (in many cases, in fact), repair isn't a realistic option anyway. Severely damaged ships have often been declared beyond economic repair and scrapped or scuttled (and cannibalised for spares), whilst in some ships it was decided that particular damage was not worth repairing but the ship itself kept operational at reduced capability (you may have sen those photos of WARSPITE conducting shore bombardment using A, B and Y turrets, but with X turret trained fore and aft and not firing - because the turret had been damaged some time earlier and, given the predicted course of the war and the availability of more modern platforms, it was decided not to bother with the repairs).
Its a fascinating subject (well, it is to me anyway) and something that me and some of my colleagues have wrestled with in the "real world" for a while now.