I have a database with a table of login and logoff times for staff.
Im looking for which staff clocked on or off between Sunday 6am and Thursday 4am or Saturday 6:30am and Saturday 3pm.
I want the end user to be able to select any date range from a web interface (ie 1/1/14 start and 12/1/14 end) and from this work out who worked during the day and time ranges. I want to be able to display a list of workers and their login and logoff time.
thus far I have worked out how to check if a user has logged by using Determine Whether Two Date Ranges Overlap
But im stumped with the pseudo code for how to work out the daterangeB
so far I have:
start at datefrom,
check if datefrom = dateto, if true end loop,
find out day name,
check if saturday, if saturday add timestamps to array (start and finish),
increment datefrom by 1 day, start loop again.
this will give me an array of the saturday daterangeB's between the dates selected by the user.
However the bigger date range is an issue, because its possible that the first day is say a Tuesday, and if i'm checking for Sundays and Thursday, say i find a Thursday, i won't have a start day as sunday, I will need to make the Tuesday at 00:00:00. And similarly the opposite could happen, i could find a Sunday, and the last day that the user selects could be a Monday and therefore I need to make that the end date for daterangeB
start at datefrom,
check if datefrom = dateto, if true end loop,
find out day name,
check if Sunday, if Sunday add timestamp to array (start),
increment datefrom by 1 day, start loop again.
and
start at datefrom,
check if datefrom = dateto, if true end loop,
find out day name,
check if Thursday, if Thursday add timestamps to array (start and finish),
increment datefrom by 1 day, start loop again.