title: calculating Total Length of stay for a bed occupancy rate Formula in sql
body: <p>we have a table named PatientAdmissions listed below <a href="https://i.stack.imgur.com/OYNqU.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OYNqU.jpg" alt="enter image description here"></a></p>
  
  <p>I'm trying to get the Total Length of stay which is the Total Date difference between the AdmitDate and the DischargeDate in a provided period of time from the user by (AdmitDate as FromDate,DischargeDate as ToDate) 
  and then apply the following formula 
  <a href="https://i.stack.imgur.com/1du45.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1du45.jpg" alt="enter image description here"></a></p>
  
  <p>and the Number of Days in the period would be AdmitDate as FromDate and DischargeDate as ToDate 
  , I couldn't figure out a way to write the query without getting any e error's </p>