antiskeptic
Programmer
I have never written a cursor from scratch...so I'm completely befuddled as to where to start, can anyone help me?
I started this thread a couple days ago looking for a solution...and realized, and was told, that a LOOP or Cursor would be my only option...so here goes...
I am working on a employee time database. I have to make a report to get the time off of people who have 3 or more consecutive days of PTO (Paid time off). Now consecutive days can be 1,2,3...or if there is a holiday or weekend, it could end up being 3,5,6... If there is a timecode on the day, I don't care if 4 days have passed since the last one...it is the next "consecutive" day. See the output of my table below for an example of what I'm looking for.
Name TimeCode ItemDate
George Jetson PTO 2004-08-09
George Jetson WT 2004-08-10
George Jetson WT 2004-08-11
George Jetson WT 2004-08-12
George Jetson WT 2004-08-13
George Jetson PTO 2004-08-18
George Jetson PTO 2004-08-19
George Jetson PTO 2004-08-20
Fred Flintstone WT 2004-08-11
Fred Flintstone PTO 2004-08-12
Fred Flintstone PTO 2004-08-13
Fred Flintstone PTO 2004-08-16
Fred Flintstone WT 2004-08-17
Fred Flintstone WT 2004-08-18
Fred Flintstone WT 2004-08-19
Fred Flintstone WT 2004-08-20
Johnny Quest WT 2004-08-11
Johnny Quest PTO 2004-08-12
Johnny Quest PTO 2004-08-13
Johnny Quest WT 2004-08-16
Johnny Quest PTO 2004-08-17
Johnny Quest PTO 2004-08-18
Johnny Quest WT 2004-08-19
Johnny Quest WT 2004-08-20
Now George has the 18, 19, & 20th as paid off so I would want to see him on the report for those days.
Fred would also appear on the report even though the dates are not exactly consecutive. The skip in dates from the 13th to the 16th is over a weekend, so for the purposes of this data output, this is considered consecutive.
And Johnny would not show up at all because he only takes off 2 days at a time.
So I need to figure out how to count (like a running total) the codes when they switch from WorkTime (WT) or PaidTimeOff (PTO). And be able to take into consideration skipped over days. The only way the PTO "breaks" is if a WT timecode interrupts the "flow". (If that makes any sense) ANd I don't care about any of the PTO if it's not 3 days or more in a row.
Can anyone see of a way I can do this?
From the above example...my final output needs to be like this:
Name TimeCode Min Date Max Date
George Jetson PTO 2004-08-18 2004-08-20
Fred Flintstone PTO 2004-08-12 2004-08-16
Thanks in advance for any tips, pointers, or shoves in the right direction. Thank you!
Sincerely,
Antiskeptic
I started this thread a couple days ago looking for a solution...and realized, and was told, that a LOOP or Cursor would be my only option...so here goes...
I am working on a employee time database. I have to make a report to get the time off of people who have 3 or more consecutive days of PTO (Paid time off). Now consecutive days can be 1,2,3...or if there is a holiday or weekend, it could end up being 3,5,6... If there is a timecode on the day, I don't care if 4 days have passed since the last one...it is the next "consecutive" day. See the output of my table below for an example of what I'm looking for.
Name TimeCode ItemDate
George Jetson PTO 2004-08-09
George Jetson WT 2004-08-10
George Jetson WT 2004-08-11
George Jetson WT 2004-08-12
George Jetson WT 2004-08-13
George Jetson PTO 2004-08-18
George Jetson PTO 2004-08-19
George Jetson PTO 2004-08-20
Fred Flintstone WT 2004-08-11
Fred Flintstone PTO 2004-08-12
Fred Flintstone PTO 2004-08-13
Fred Flintstone PTO 2004-08-16
Fred Flintstone WT 2004-08-17
Fred Flintstone WT 2004-08-18
Fred Flintstone WT 2004-08-19
Fred Flintstone WT 2004-08-20
Johnny Quest WT 2004-08-11
Johnny Quest PTO 2004-08-12
Johnny Quest PTO 2004-08-13
Johnny Quest WT 2004-08-16
Johnny Quest PTO 2004-08-17
Johnny Quest PTO 2004-08-18
Johnny Quest WT 2004-08-19
Johnny Quest WT 2004-08-20
Now George has the 18, 19, & 20th as paid off so I would want to see him on the report for those days.
Fred would also appear on the report even though the dates are not exactly consecutive. The skip in dates from the 13th to the 16th is over a weekend, so for the purposes of this data output, this is considered consecutive.
And Johnny would not show up at all because he only takes off 2 days at a time.
So I need to figure out how to count (like a running total) the codes when they switch from WorkTime (WT) or PaidTimeOff (PTO). And be able to take into consideration skipped over days. The only way the PTO "breaks" is if a WT timecode interrupts the "flow". (If that makes any sense) ANd I don't care about any of the PTO if it's not 3 days or more in a row.
Can anyone see of a way I can do this?
From the above example...my final output needs to be like this:
Name TimeCode Min Date Max Date
George Jetson PTO 2004-08-18 2004-08-20
Fred Flintstone PTO 2004-08-12 2004-08-16
Thanks in advance for any tips, pointers, or shoves in the right direction. Thank you!
Sincerely,
Antiskeptic