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 [of 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. If the balloting does not result in an election, even after the provisions of No. 74 have been fulfilled, the Cardinal electors shall be invited by the Camerlengo to express an opinion about the manner of proceeding. The election will then proceed in accordance with what the absolute majority of the electors decides.
Nevertheless, there can be no waiving of the requirement that a valid election takes place only by an absolute majority of the votes or else by voting only on the two names which in the ballot immediately preceding have received the greatest number of votes; also in this second case only an absolute majority is required.
There are two ballots per day, so the provisions of Norm 75 come into play after fifteen days. The cardinals may decide to carry on with the groups of seven ballots indefinitely, or to bring deliberations to a swift conclusion by choosing between the two highest-polling candidates in the last ballot (or, indeed, to do anything else allowed by the Constitution).