Mean and variance of truncated generalized Beta distribution The generalized Beta probability density function is given by:
$$f(x) = \frac{(x-A)^{\alpha - 1} (B-x)^{\beta - 1}}{(B-A)^{\alpha + \beta - 1} \mathrm{B}(\alpha ,\beta)}$$
for $A<x<B$, and $f(x) = 0$ otherwise. Here $\alpha>0$ and $\beta>0$.
Let $g(x)$ be a  truncated version of this distribution in the interval $[a,b]$, where $A\le a \le b \le B$. That is, $g(x)\propto f(x)$ if $a\le x\le b$, with a proportionality constant that normalizes $g(x)$, and $g(x)=0$ otherwise.
Write explicit formulas (without integrations or infinite sums; you can use special functions) for the first and second moments of $g(x)$:
$$\langle x \rangle_g = \int_{-\infty}^\infty x g(x)\mathrm{d}x$$
$$\langle x^2 \rangle_g = \int_{-\infty}^\infty x^2 g(x)\mathrm{d}x$$
 A: I found explicit formulae using the generalized incomplete Beta function defined as follows (this is a standard special function available in numerical packages):
$$\mathrm{B}\left(z_{1},z_{2};\alpha,\beta\right)=\int_{z_{1}}^{z_{2}}x^{\alpha-1}\left(1-x\right)^{\beta-1}\mathrm{d}x$$
It follows that
$$g(x) =  \frac{1}{Z}\left(x-A\right)^{\alpha-1}\left(B-x\right)^{\beta-1}$$
with the normalization constant
$$Z=\int_{a}^{b}\left(x-A\right)^{\alpha-1}\left(B-x\right)^{\beta-1}\mathrm{d}x
=\left(B-A\right)^{\alpha+\beta-1}\mathrm{B}\left(a,b;\alpha,\beta\right)$$
Instead of computing  $\left\langle x\right\rangle$ and $\langle x^2\rangle$ directly, we compute $\langle x-A\rangle$ and $\langle (x-A)^{2}\rangle$. We have:
$$\left\langle x-A\right\rangle =\frac{1}{Z}\int_{a}^{b}\left(x-A\right)^{\alpha}\left(B-x\right)^{\beta-1}\mathrm{d}x
=\frac{1}{Z}\left(B-A\right)^{\alpha+\beta}\mathrm{B}\left(a,b;\alpha+1,\beta\right)
=(B-A)\frac{\mathrm{B}\left(a,b;\alpha+1,\beta\right)}{\mathrm{B}\left(a,b;\alpha,\beta\right)}$$
and, similarly:
$$\langle \left(x-A\right)^{2}\rangle =\left(B-A\right)^{2}\frac{\mathrm{B}\left(a,b;\alpha+2,\beta\right)}{\mathrm{B}\left(a,b;\alpha,\beta\right)}$$
From these it is easy to get $\langle x \rangle$ and $\langle x^2 \rangle - \langle x \rangle^2$:
$$\langle x \rangle = \langle x - A \rangle + A$$
$$\langle x^2 \rangle - \langle x \rangle^2 = \langle (x-A)^2 \rangle - \langle x-A \rangle^2$$
Perhaps some simplifications are possible, but I do not know them. If someone can help on that it would be awesome.
A: A neat way is to work with a standard Beta distribution, and doubly truncate that. 
Let $X \sim Beta(\alpha,\beta)$ with pdf $f(x)$, and impose lower and upper truncation points $a_0$ and $b_0$. 
Let $g(x) = f(x \, \big| \, a_0 < X < b_0)  = \large\frac{f(x)}{P(a_0<X<b_0)}$ denote the pdf of the doubly truncated standard Beta, i.e. 

Then, $E_g[X]$ is:

and $E_g[X^2]$ is:

where I am using the Expect function from the mathStatica package for Mathematica to do the nitty-gritties.
Transform from standard Beta to Generalised Beta
By definition, if $X \sim Beta(\alpha,\beta)$, then $$X_{Gen} = A+(B-A)X \, \sim \, GeneralisedBeta(\alpha,\beta,A,B)$$
It follows that the mean of the doubly truncated generalised Beta (truncated above at $b$ and below at $a$, such that $A<a< X_{Gen} < b<B$) is:
$$\begin{align*}\displaystyle   E\big[X_{Gen} \, \big| \, a < X_{Gen} <b\big]  \quad &=  \quad A + (B-A) E_g[X]   \\ &=  \quad A + (B-A) \frac{\text{Beta}(b_0,\alpha +1,\beta )-\text{Beta}(a_0,\alpha +1,\beta )}{\text{Beta}(b_0,\alpha ,\beta )-\text{Beta}(a_0,\alpha ,\beta )} \end{align*}$$
where:
$$a_0 = \frac{a-A}{B-A}    \quad  \text{ and } \quad   b_0 = \frac{b-A}{B-A} $$
This is the same as the solution obtained by @becko ... except that becko forgot to transform the bounds $a$ and $b$ to $a_0$ and $b_0$.
Example
@david proposed the following numerical case:
params = {$a_0 \rightarrow \frac{a-A}{B-A}, b_0 \rightarrow \frac{b-A}{B-A}, A \rightarrow 10, B \rightarrow 40, a \rightarrow 15, b \rightarrow 25, \alpha \rightarrow 5, \beta \rightarrow 10 \quad$} 
Here is a plot, given these parameters, of:


*

*RED curve: parent generalised Beta pdf 

*BLUE curve:  doubly truncated generalised Beta pdf 



The mean $E\big[X_{Gen} \, \big| \, a < X_{Gen} <b\big]$ is:
A + (B - A) sol1 //. params // N
19.768

Notes


*

*Beta[z,a,b] denotes the incomplete beta function $\int _0^z t^{a-1} (1-t)^{b-1} d t $

*As disclosure, I should add that I am one of the authors of the mathStatica software package used above.

