As a version of the secretary problem, Ferguson, Hardwick and Tamaki (1992) considered an optimal stopping problem called the duration problem. The basic duration problem is the classical duration problem, in which the objective is to maximize the time of possession of a relatively best object when a known number of rankable objects appear in random order. In this paper we generalize this classical problem in two directions by allowing the number N (of available objects) to be a random variable with a known upper bound n and also allowing the objects to appear in accordance with Bernoulli trials. Two models can be considered for our random horizon duration problem according to whether the planning horizon is N or n. Since the form of the optimal rule is in general complicated, our main concern is to give to each model a sufficient condition for the optimal rule to be simple. For N having a uniform, generalized uniform, or curtailed geometric distribution, the optimal rule is shown to be simple in the so-called secretary case. The asymptotic results, as n → ∞, will also be given for these priors.