There is no time limit laid down. So far, every conclave in the last hundred years has lasted less than a week, but a pope can only be elected with a two-thirds majority of the College of Cardinals.
The procedure for a conclave was set out in Pope John Paul II's Apostolic Constitution Universi Dominici Gregis, promulgated on 22 February 1996, amended by the Motu Proprio Normas nonnullas of Benedict XVI, issued 22 February 2013.
No. 62 [amended by Normas nonnullas]. "Since the forms of election known as per acclamationem seu inspirationem and per compromissum are abolished, the form of electing the Roman Pontiff shall henceforth be per scrutinium alone.
I therefore decree that for the valid election of the Roman Pontiff at least two thirds of the votes are required, calculated on the basis of the total number of electors present and voting."
However, there are norms in Universi Dominici Gregis to help with an impasse.
No. 74. In the event that the Cardinal electors find it difficult to agree on the person to be elected, after balloting has been carried out for three days in the form described above (in Nos. 62ff) without result, voting is to be suspended for a maximum of one day in order to allow a pause for prayer, informal discussion among the voters, and a brief spiritual exhortation given by the senior Cardinal in the Order of Deacons. Voting is then resumed in the usual manner, and after seven ballots, if the election has not taken place, there is another pause for prayer, discussion and an exhortation given by the senior Cardinal in the Order of Priests. Another series of seven ballots is then held and, if there has still been no election, this is followed by a further pause for prayer, discussion and an exhortation given by the senior Cardinal in the Order of Bishops. Voting is then resumed in the usual manner and, unless the election occurs, it is to continue for seven ballots.
No. 75 [as amended by Normas nonnullas] If the balloting mentioned in Nos. 72, 73 and 74 ... does not result in an election, one day shall be dedicated to prayer, reflection and dialogue; in the successive balloting, observing the order established in No. 74, only the two names which received the greatest number of votes in the previous scrutiny, will have passive voice. There can be no waiving of the requirement that, in these ballots too, for a valid election to take place there must be a clear majority of at least two thirds of the votes of the Cardinals present and voting. In these ballots the two names having passive voice do not have active voice.
There are two ballots per day, so the provisions of Norm 75 come into play after fifteen days. The cardinals are given the opportunity to bring deliberations to a swift conclusion by choosing between only the two highest-polling candidates in the last ballot, after which time the process starts again.