I have developed a sharepoint list to track the overtime for the employees in my department, at this point I was able to mesure the total of hours per day, now I need to identify which hours are diurnal and nocturnal, from 7.00 pm ahead are nocturnal hours. So if the employee started overtime from 5.00 until 8.00 pm he will have 2 diurnal hours and 1 nocturnal. That is the difference that I need specify.
Thanks to all
Solved! Go to Solution.
That'll get the time difference for sure, the next bit will be around figuring out whether the hours are nocturnal.
This is quite tricky because dateDiffHours only gives us the difference in the hours, not the a minus figure to indicate whether one is greater than the other.
You might also want to use dateDiffMinutes if you need more accurate figures.
I used 1 calculated value to get 7pm in the correct format
formatDate(dateAddHours(Current Date, 19),"T")
and another to get our start time and end time in the correct format
formatDate(dateAddHours(Current Time, 7),"T") (this is just indicative, you would take your value from a control, but you need to format it in the same way)
Then I have a calculated value that checks if the start time was before 7PM and if so calculates the difference between the start time and 7PM.
"Flag" simply tells me that the start time was after 7pm.
A similar calculation for the End time after 7pm.
And then add the 2 values together to get the total hours. You can then use another IF statement to identify if either "flag" or "late flag" are the values. If they are then you wouldn't need to 2 separate values, just the total hours.
Keep in mind this is back of a fag packet stuff, I've not tested it properly, so if anyone can spot holes in this or indeed offer a better solution, go right ahead.