A modern nuclear submarine can stay under water for months at a time. The length of time it can stay submerged is limited by it's food supply onboard. Breathing air can be generated on board by the electrolysis of water. Fresh water is generated from seawater by reverse osmosis.
Submarines are capable of producing air, water, and power so the only limitation for submarines is their food supply. Submarines can stay submerged until the food is depleted.