In this paper, the optimal schedule of dispatchable distributed generation (DG) units connected to radial electrical distribution systems (EDS) is solved using an extended dynamic programming approach. The objective of the optimal DG scheduling problem is to determine the hour-by-hour active generation output of each dispatchable DG unit, in order to minimize the total active power losses of the EDS and the generation costs. The proposed extended dynamic programming (EDP) is an advantageous approach because convexity is not required to obtain a global optimal solution, and the 'curse of dimensionality' is not a concern since the computational complexity of the algorithm grows linearly with the size of the network. Besides, the state variables have only two dimensions, one to represent the active power flows and the other to represent the nodal voltages. A 56-nodes MV distribution system with two dispatchable DG units is used to evaluate the performance of the proposed EDP approach, considering a deterministic and a stochastic case. A set of Monte Carlo simulations is used to analyze the influence of uncertainties. Results confirm that the proposed methodology is a suitable approach to unveil the best operation schedule for dispatchable DG units.