In this study, two scenarios of hybrid energy systems are considered each contains a different combination of solar photovoltaic (SPV), wind turbine (WT), diesel generator (DG set), converter system and storage battery in off-grid mode and grid-connected mode. In this study, Hybrid Optimization Model for Electric Renewable (HOMER) software is used for financial and technical analysis of the system. The optimal size of off-grid and grid-connected hybrid energy system having SPV-wind-diesel-battery has been calculated based on solar radiation, hourly wind data and electricity demand for the site under study. The simulation results shows that in case of off-grid optimal hybrid system having a cost analysis as cost of energy (COE) of $0.320/kWh, net present cost (NPC) of $294028, operating cost of $8014, and initial capital cost of $190430 whereas for grid-connected system cost analysis are COE of $0.108/kWh, NPC of $99746, operating cost of $7001, initial capital cost of $9245. These costs are for energy demand of 195kWh/day and peak load of 28 kW for institutional loads. The results clearly indicate that the grid-connected hybrid system is best from an economic point of view and the off-grid system is suitable from the environmental point of view.