Jump to content

combining consecutive sets of dates


Guest spooks

Recommended Posts

Guest spooks

What I need is to take a table and combine all records that have an end date on a particular date as well as a start date (in another record) that is on the day after the end date.So for example an employee goes on holiday on from 1 july 2010 to 3 july 2010 and then they go on holiday again from 4 july 2010 to 7 july 2010.So I need to loop through the whole table and join all records with dates that are right next to each other.So a better example would be:Start Date - End Date - Employee no2001/01/03 - 2001/01/14 (00055)2001/01/15 - 2001/01/23 (00030)2001/07/01 - 2001/07/03 (00030)2001/07/04 - 2001/07/07 (00030)2001/08/10 - 2001/08/15 (00030)2001/08/16 - 2001/08/20 (00055)Thus if these were the dates of the holidays taken in a year by employees, I would run through the entire table and join only the 3rd and 4th row because they the 4th of july is the day after the 3rd of july and both records are for the same employee (00030).(Thus effectively the employee was on holiday from the 1st of July to the 7th of July)The End result (my new table) would look like this:Start Date - End Date2001/01/03 - 2001/01/14 (00055)2001/01/15 - 2001/01/23 (00030)2001/07/01 - 2001/07/07 (00030)2001/08/10 - 2001/08/15 (00030)2001/08/16 - 2001/08/20 (00055)Would it be best to pull all records into an array and then join the relevant records and then insert all records from the array back into the database?If so, how do I compare/join/delete records from the array.Any help or direction would really be appreciated.Thanks

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...