According to Laws: 3.8, 3.9, the match will be resumed if rain gets stopped within game time, light and weather conditions are good and ground and pitch get suitable to resume match.
So it depends on total time allocated for that single game. In a T20 match, time allocated for a single innings is usually 100 minutes and for ODI, time for a single innings allocated is 3.5 hours. So, approximately 4 hours are usually allocated for a single T20 match and 8 hours for a single ODI match.
If rain gets stopped within time, umpires check how much time for that game has been left (excluding drinks and innings breaks) and how much overs can be bowled in that time according to 14 overs per hour. The match would be then resumed according to revised reduced overs.
Umpires apply D/L Method to update scores to compensate overs reduction whether its first innings or second innings of the match.
If rain doesn't stop within game time then there are two cases; If rain interrupts in second innings of the match, then D/L method would declare winner of the match otherwise if rain interrupts the match before second innings gets started, then the match would be considered as draw.