It is easy to show that if you can only earn $p$ or $q$ coins, with $p$ and $q$ coprimes, the largest number of coins which cannot be earned is $pq-p-q$.
If we have two hourglasses that last $p$ and $q$ minutes respectively, the longest number of minutes which cannot be measured is smaller: for example, if they last 9 and 13 minutes it is possible to measure 17 minutes by starting them together, turning the first one when it's empty, and turning it again when the second one is empty. When the first hourglass becomes empty again, 17 minutes are elapsed.
Is there a formula which gives the longest number of minutes which cannot be measured?
If you start the two hourglasses together, run $p$ through $k$ cycles, and turn over $q$ when the $k^{\text{th}}$ cycle of $p$ is done, you get $kp+(kp \bmod q)$ Similarly you can get $kq+(kq \bmod p)$. You can view it as a Frobenius problem with a larger set of numbers available. In your example, we have the following added numbers $$\begin {array} {r|r|r} k&p&q\\ \hline 1&-&17\\2&23&34\\3&28&42 \end {array}$$ You have the Frobenius problem with $\{9,13,17,23,28,42\}$ and my hand calculations show the largest nonrepresentable number to be $47$, improved by Roddy MacPhee to $38$. The Frobenius problem does not have a known solution for more than two sizes of coin.