I'm working on a working time database.
I would like to calculate the work hours per day for a single user.

The problem which is causing me some troubles is that sometimes the users are working over midnight, so I have only a work left time or work arrive time.

I don't now if I have to use a query or code in order to calculate the time.

Here are also some examples:
UserID Date Time Event
1 10.12 3:00 LeftWork
1 10.12 14:00 ArriveWork
1 10.12 22:00 LeftWork

In the example above the total working hours are 11.
I cant find the right query in order to give me the correct result.

There can be also the following situaton:
UserID Date Time Event
1 15.12 7:00 ArriveWork
1 15.12 15:00 LeftWork
1 15.12 23:00 ArriveWork

The working hours are 9.

Thanks in advance.