beta distribution on arbitrary interval

Given that I can simulate $X \sim Beta(a,b)$ on $(0,1)$, how can I simulate $Y \sim GBeta(a,b)$ (generalized beta) on $(p, q)$ for arbitrary $p, q \in \mathbb{R}$? Is it just $Y = (p-q) X + p$

$$Y = X \times (q - p) + p$$