At any given time, a battery unit can only be in either of two states: It is either charging or discharging. For a microgrid with a rolling time horizon partitioned into a fixed number of specific time intervals, an optimal battery power scheduling is therefore inevitably discrete in nature, and one may have to resort to very complex and time-consuming mixedinteger programming techniques. In this paper, we show that this can in many cases be avoided by introducing small perturbing cost elements in an alternative convex formulation where the solution can be forced to take unique battery charge/discharge states (or configurations) without the need to employ integer variables. A formulation is then obtained which can be solved by using very efficient disciplined convex programming techniques. The new approach is demonstrated by formulating an explicit theory comprising of eight propositions with proofs which are associated with a small generic case consisting of one battery unit, two renewable energy sources, a general-purpose power grid, and one consumer. The general procedure can be straightforwardly extended to higher dimensions. Numerical examples are included to illustrate the theory based on a 24-hour spot price scenario. In particular, it is also demonstrated how a suitably chosen convex battery cost can provide an efficient threshold to avoid unnecessary battery use, and thereby promote a longer lifetime.