Date Interval within a specific span

L - Jul 19, 2015 at 03:15 AM

I need some help with calculating the time difference between two time stamps within a specific span (like 12.30 PM to 22.30 PM). For Eg

Date 1 - 6/26/2015 12:10:11 AM
Date 2 - 6/24/2015 20:30:43 PM

I need the difference in hours or days between these just for the 10 hours in each day. Manually calculating this, I should get 2 hours on 24th + 10 hours on 25th = 12 total hours or 0.5 days. If both dates are outside the required time interval, then just calculate the difference (like between 12AM to 6 AM on the same day).

Thanks for your assistance on this.