Modified to allow calculation of night shifts
The following code incorporates prior comments and can handle night shifts which span over a single day (for instance: someone works from 2pm to 2am the next morning).
Another modification is that this function will return the result in minutes...
Function needs repair...
it does not handle well night shifts. If a day starts at 2PM and ends at 2AM the next day the function returns negative values