In the very beginning of the Walking Dead series if I recall correctly, Rick has been in coma for over a month, yet he managed to survive. We don't know exactly when the hospital got over-run but judging from his first observations - it has been a while.
There are some questions on SFF getting at this same topic if you want to read those:
And this HitFix article provides some insight:
But I will do my best to sum them up.
The gist of them is that, although we don't see the passage of time with him, in can be deduced that he has been in a coma about a month. Here is a snippet from phantom42's answer to How Long Was Rick in the Hospital:
Dave Erickson, the showrunner for Fear the Walking Dead, got a word-of-god answer on this from series creator Robert Kirkman.
In his interview with Tech Insider, Erickson said:
"Robert has said for him, the coma, Rick was probably out four to five weeks.."
We know Rick was already into his coma before things start coming unhinged, and Shane paid him a few visits (I'll have to track down specifics). The last time Shane was in the hospital, it was not to bring flowers or pray for recovery; the outbreak was already occurring, and Shane was trying to get Rick out.
Josh's answer on Why was Rick's room blocked with a hospital bed? breaks down Shane's actions, reactions, and intentions pretty clearly, but the main points are that
- Shane was at the hospital trying to get Rick to safety, in light of the outbreak and the military presence that has begun to combat any perceived threats.
- Shane cannot move Rick easily with Rick connected to various equipment.
- Running out of time and options, Shane does the best he can and blocks the door to Rick's room with a bed in the hall.
Now, the HitFix article using images and logic to assume how much more time has passed, notably linking the state of the hospital interior to a military barrage.
How Rick survived presumably without fluids, and how the backup lights stayed on in the hospital could probably be debated at length. Obviously, the biggest explanation for Rick's survival is he is a key character in the show. That kind of means he should be alive, and probably that he should be capable of feats that no one else on the show (or in reality) would be capable of replicating. But he's more than just a character in a show...
In the last panel, we see Lori say
"They said people were going to stay at the hospital when they evacuated. From what you told me... they must have abandoned the hospital less than a week after we left."
I am less versed on the comics, but if we can believe that Shane and Lori evacuated at the same, then I think we can assume that Rick was in the hospital, alone and in a coma, for no less than a week before waking up.
That's obviously on the lower end, but it's more believable. After all, he wasn't alone the whole time he was in a coma, or even the whole time people started knowing about the outbreak. In his month of being dead to the world, I'll buy it that he pulled through a week on his own.
Ryan H.'s answer from How many days passed between the initial outbreak and “Chupacabra” in The Walking Dead? which spawned the question How long was Rick in the hospital? ends with:
In a real world scenario Rick needs to wake up very soon to survive. One to two days after the ancillary staff have left the hospital.
Well...this is pseudo-scifi after all... Close enough?
In the first episode, you see Rick rip an IV hooked up to a fluids bag out of his arm. That would have provided him the ability to survive for longer than 3 days it takes for you to thirst to death when you are in the complete absence of liquids. We know from episodes in season six that a cheesemaker can starve a man to death in 47 days, but that is assuming he has water. Rick looks slightly emaciated when he wakes up and is obviously very thirsty because he tries to scream for water, but he woke up in time to survive his ordeal.