It seems to me that there would be three groups that need to be summed.
1. Those that were hired before or on the first day of the month AND terminated on or after the last day of the month OR not terminated.
2. Those that were hired before or on the first day of the month AND terminated before the last day of the month.
3. Those that were hired after the first day of the month AND before the last day of the month AND terminated on or after the last day of the month OR not terminated.
I believe that the following formula covers those three groups:
Note that after the formula is activated in cell MC46 the fill handle may be dragged down to MC47 and then, while MC46:MC47 are still selected, over to cell MN47.
Let us know if you have any questions.
EDIT: I forgot to mention that I added two columns (M:N) on the HC DBV sheet (see the attached file).
Column M shows the salary for the first month of employment using: =(EOMONTH(C9,0)-C9)/DAY(EOMONTH(C9,0))*L9
Column N shows the salary for the last month of employment using: =IF(D9="",1,(D9-(EOMONTH(D9,-1)+1))/DAY(EOMONTH(D9,0)))*L9
Bookmarks