I have a table with 3 columns StartDate, EndDate, ElapsedTimeInSec.
I use an AFTER INSERT trigger to calculate the ElapsedTimeInSec.
I would like to do this:
-
If my start date is
2011-11-18 07:30:00and my end date2011-11-18 9:30:00which give me aElapsedtimeInSecof 7200 I would like to be able to split it this way. -
Row 1 : 2011-11-18 07:30:00 / 2011-11-18 08:00:00 / 1800
- Row 2 : 2011-11-18 08:00:00 / 2011-11-18 09:00:00 / 3600
- Row 3 : 2011-11-18 09:00:00 / 2011-11-18 09:30:00 / 1800
How can I achieve this result ?
I dont think I made my explaination clear enough.
I have an actual table with data in it which as 2 field one with a StratDowntime and one with a EndDowntime and I would like to create a view of hours per hour base on a production shift of 12 hours (07:00:00 to 19:00:00) of the downtime.
So If I have a downtime from 2011-11-19 06:00:00 to 2011-11-19 08:00:00 I want in my report to see from 07:00:00 so the new rocrd should look like 2011-11-19 07:00:00 to 2011-11-19 08:00:00.
Another example if I do have downtime from 2011-11-19 10:30:00 to 2011-11-19 13:33:00 I should get in my report this
– 2011-11-19 10:30:00 to 2011-11-19 11:00:00
– 2011-11-19 11:00:00 to 2011-11-19 12:00:00
– 2011-11-19 12:00:00 to 2011-11-19 13:00:00
– 2011-11-19 13:00:00 to 2011-11-19 13:33:00
I hope this will clarify the question because none of the solution down there is actually doing this it is close but not on it.
thanks
You could try something like: