This research proposes a day-ahead scheduling utilizing both demand side management (DSM), and Energy Management (EM) in a grid-tied nanogrid comprises of photovoltaic, battery, and diesel generator for optimizing the generation cost and the energy not supplied (at grid-outage). Wider terminology is introduced to combine both load controllability (considered in traditional DSM), and interval capability to accommodate additional loads defined as flexible, non-flexible, and semi-flexible intervals. Moreover, the user selection for EM or combined operation of EM with DSM at different degrees of interval flexibility is defined as user preference. In addition, three utility’s operations are considered denoted as fixed rate pricing (FRP), time-of-use (ToU) pricing, and FRP with grid-outage. Hence, the suggested framework utilizes the opportunities of generation diversity, the electricity pricing strategy, and the load flexibility. The obtained result show that, DSM with flexible intervals reduces the cost by 21.02%, 25.23%, and 18.15% for FRP, ToU, and FRP with grid-outage scenarios respectively. And cost reduction by 20.41%, 22.42%, and 17.81% for DSM with semi-flexible intervals and 16.24%, 21.15%, and 13.8% for DSM with non-flexible intervals. This cost reduction is associated with full utilization of renewable energy generation and reduction of the energy from/to battery which enhances its lifetime or reduces the required battery size during design stage for cost and provisions saving in flexible and semi-flexible intervals. A hybrid optimization technique of Moth-flame optimization algorithm, and Lagrange’s multiplier is proposed and confirms its effectiveness with detailed comparison with other techniques.