The implementation of Electronic Health Records (EHR) in hospitals has many benefits and this healthcare technology (HCT) impact the providers, patients and payers in various ways. One of the great benefits is the analysis and investigation of the length of stay (LOS) in hospital based on EHR system. LOS is an important indicator for testing and evaluating the performances of the hospitals. The present study targeted to analyze and investigate LOS in Yanbu General Hospital based on the data retrieved from the database of its Electronic Health Record between the periods of 2018 to 2021. We determined the average LOS in the hospital per month, the average LOS in the hospital per department over the 4 years to define the long-term hospitalization patients per department including LOS analysis in terms of transfer time and pattern. On an average a 65 percent (27,914) of hospitalized patients was discharged in around 4.5 days, and approximately 20 percent (8589) left the hospital within less 3 days, and 15 percent (6441) of patients stayed longer than 4.5 days. The results showed the year of 2018 had the highest average LOS of 7 days. Intensive Care Unit (ICU) had highest average LOS of 16 days and Female Surgical Ward (FSW) had the lowest average LOS of 4 days. We also examined the impact of discharge delay time, transfer time, restored medical history of patients, age, gender, and severity wards on average LOS. Parameters are identified for developing future predictive model based on obtained data using the regression analysis approach and machine learning techniques which is in progress. A successful control of LOS for inpatients would result in care cost reduction, improvement in the quality of treatment, more efficient bed management and lastly control the risk of infection for inpatients.