Assume that $X(t) = \mu t + \sigma W(t)$, where $W$ is a standard Brownian motion and $\mu > 0$, and define $$ T = \int_0^\infty I(X(t) \in (0,\delta))\ dt $$ where $\delta >0$. What is $E(T)$?
There seems to be a number of questions (and answers) on first passage times, but nothing out there on sojourn times.
This is taken from Joseph T. Chang's course on stochastic processes (see Chang's webpage).
Note that, by definition of $T$ and by the scaling properties of Brownian motion, $$ E(T)=\int_0^\infty P(0\lt X(t)\lt\delta)\,\mathrm dt=\int_0^\infty P(x_\delta(t)\lt \xi\lt x_0(t))\,\mathrm dt, $$ where $\xi$ denotes a standard normal random variable and, for every nonnegative $\delta$, $$ x_\delta(t)=\mu\sqrt{t}/\sigma-\delta/(\sigma\sqrt{t}). $$ Let $t_\delta$ denote the inverse function of $x_\delta$, that is, for every nonnegative $\delta$ and every $x$, $t_\delta(x)$ denotes the unique nonnegative solution $t$ of the equation $$ \mu\sqrt{t}/\sigma-\delta/(\sigma\sqrt{t})=x. $$ For example, $t_0(x)=x^2\sigma^2/\mu^2$, $t_\delta(x)\geqslant t_0(x)$ for every nonnegative $\delta$ and every $x$, and $$ [x_\delta(t)\lt \xi\lt x_0(t)]=[t_0(\xi)\lt t\lt t_\delta(\xi)], $$ hence $$ E[T]=E[t_\delta(\xi)]-E[t_0(\xi)]. $$ Note that $t_\delta(x)$ solves $\mu t-x\sigma\sqrt{t}-\delta=0$ and that $\mu\gt0$, thus, $$ t_\delta(x)=\left(\frac{x\sigma+\sqrt{x^2\sigma^2+4\delta\mu}}{2\mu}\right)^2=\frac{x^2\sigma^2+2\delta\mu+x\sigma\sqrt{x^2\sigma^2+4\delta\mu}}{2\mu^2}. $$ The distribution of $\xi$ is even hence $$ E\left(\xi\sqrt{\xi^2\sigma^2+4\delta\mu}\right)=0, $$ which implies that $$ E[t_\delta(W_1)]=\frac{\sigma^2+2\delta\mu}{2\mu^2}, $$ and one is left with $$ E(T)=\frac\delta\mu. $$ More generally, for every Borel subset $B$ of $\mathbb R_+$, the time $T_B$ spent by $X$ in $B$ has expectation $$ E(T_B)=\frac{\mathrm{Leb}(B)}\mu. $$