I have a workbook, in which a row basically looks like this:

Now, I want to insert formulas into column G which calculates the something similar to the following:
=if(isblank(J1);"";(I1+J1)-(A1+B1))
Simple enough so far. The problem is that columns B and J sometimes will contain dates in addition to the time values, and I suspect that it'd be possible for a user to input time values in columns A and I as well. So is there any way to extract just time / date value from the different columns and use those in the formula?

And what is the best way to generate the formula when I want it to be created when a value is put into the corresponding row in column E? Getting the event to fire when that is done isn't a problem, but getting the cell-names / addresses is a bit of a pain? Any simple way to do this?