For a spectrally negative Lévy process X, consider
$g_t$ and its infinitesimal generator. Moreover, with
$t\geq 0$, the last time X is below the level zero before time
$\{(g_t,t, X_t), t\geq 0 \}$ the length of a current positive excursion, we derive a general formula that allows us to calculate a functional of the whole path of
$U_t\,:\!=\,t-g_t$. We use a perturbation method for Lévy processes to derive an Itô formula for the three-dimensional process
$ (U, X)=\{(U_t, X_t),t\geq 0\}$ in terms of the positive and negative excursions of the process X. As a corollary, we find the joint Laplace transform of
$(U_{\mathbf{e}_q}, X_{\mathbf{e}_q})$, where
$\mathbf{e}_q$ is an independent exponential time, and the q-potential measure of the process (U, X). Furthermore, using the results mentioned above, we find a solution to a general optimal stopping problem depending on (U, X) with an application in corporate bankruptcy. Lastly, we establish a link between the optimal prediction of
$g_{\infty}$ and optimal stopping problems in terms of (U, X) as per Baurdoux, E. J. and Pedraza, J. M.,
$L_p$ optimal prediction of the last zero of a spectrally negative Lévy process, Annals of Applied Probability, 34 (2024), 1350–1402.