0

I would like to calculate the a time interval between two time points in hourly based (calculate working hours for employees). For instance,

Start Time 4/11/2014 9:00
End Time 5/11/2014 10:00

For this case, the result should be 9 hours (since the time slot for employee is 09:00-13:00,14:00-18:00, 8 hours each day).

However, I would like remove the weekend hours from my time interval. For example,

Start Time 31/10/2014 9:00

End Time 3/11/2014 10:00

In this case, the answer should be 9 hours as well, since Nov 1st and 2nd are Sat and Sun respectively.

How could I achieve this goal using R programming. Sincerely thanks for reply.

  1. 4/11/2014 9:00
    4/11/2014 10:00 expected result: 1

  2. 4/11/2014 9:00
    4/11/2014 15:00 expected result: 5

  3. 4/11/2014 9:00
    4/11/2014 18:00 expected result: 8

  4. 4/11/2014 9:00
    5/11/2014 10:00 expected result: 9

  5. 31/10/2014 9:00
    3/11/2014 10:00 expected result: 9

Ryan Yang
  • 1
  • 1
  • Thanks,this is just an example, the format is day/month/year. I want to extract a time interval between these time points, for this case, the result should be 9 hours (since the time slot for employee is 09:00-13:00,14:00-18:00, 8 hours each day). However, I don't know how to "remove" weekend in my calculation. I should use the word "remove" instead of "extract", sorry for that. – Ryan Yang Nov 04 '14 at 04:45
  • Could you show an example that mimics your original dataset, ie. 10-12 lines of data. and the expected result. – akrun Nov 04 '14 at 04:49
  • Sorry it's my first time using stackoverflow, I edited my question and please kindly refer to it. I have data.frame with to columns and their name is Start.Time and End.Time respectively – Ryan Yang Nov 04 '14 at 05:12

0 Answers0