Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variable problem

Status
Not open for further replies.
Mar 10, 2004
53
US
I'm creating an employee labor report that calculates the amount of break time they took and if they took enough time for their break.

The data coming in from the db is as follows:

empid, workdate, punchIn, punchOut, startReason, endReason
100,3/1/04,3:00pm,6:00pm,newShift,out
100,3/1/04,6:30pm,7:30pm,mealbreak,out

With the above data, the mealbreak actually started at 6pm and ended on 6:30pm for a total time of 30min.

I've created variables to capture the mealbreak start time and end time.

//@startbreak
whileprintingrecords;
if {tblname.startReason} = "newShift" then {tblname.punchOut}

//@endbreak
whileprintingrecords;
if {tblname.startReason} <> "newShift" then {tblname.punchIn}

I've grouped the data by empid, and placed the both formula on the detail section. The @startbreak is ending up as blank once it hit the second record for the same employee.
How do I retain the initial value of @startbreak?
 
I'm not quite clear what you're after. But in Crystal 8.5, something like
Code:
 previous({tblname.punchOut})
might do the job.

Madawc Williams
East Anglia, Great Britain
 
apart from the tecnical problem, I think you're wrong to take the newshift for trigger.
At punchout time you don't know the reason for the break, unless the employee didn't give the right endReason for the first record in your sample?

your sample:
empid, workdate, punchIn, punchOut, startReason, endReason
100,3/1/04,3:00pm,6:00pm,newShift,[highlight]out[/highlight]
100,3/1/04,6:30pm,7:30pm,[highlight red]mealbreak[/highlight],out

would be :
empid, workdate, punchIn, punchOut, startReason, endReason
100,3/1/04,3:00pm,6:00pm,newShift,[highlight lightgreen]mealbreak[/highlight]
100,3/1/04,6:30pm,7:30pm,[highlight lightgreen]mealbreak[/highlight],out

but this means there is a double info for mealbreak, but it can work as a validity check on entry like

If the entry reason is not compatible with the exit reason, ask the employee to confirm which one is right.

The quality of the report is at first of the basic information quality level, the program will not improve it!


--------------------------------------------------
[highlight]Django[/highlight] [thumbsup]
bug exterminator
tips'n tricks addict
 
The data is coming from punch clocks that only passes time information to the timekeeping program and the program somehow figures out if the punch out was for a meal break or if it is for an end of shift(work).

The sample data I've provided is exactly how I see the data in the db with both record's endReason as being "out".

The report I'm trying to achieve is something like:


Date EmpID Duration of Break

3/1/04 100 30 Min

Somehow I need to store the punchOut date/time for the record that has the "newSHift" as the startreason and also store the punchOut data for the record that have "mealbreak" as the startReason and use both to come up with the duration of the meal break. I thought the @startbreak variable I created (see orig post) would do the trick but it's not.

Potentially an employee can work two shifts in one day and have two meal breaks. The data in the db then looks like:

empid, workdate, punchIn, punchOut, startReason, endReason
100,3/1/04,3:00pm,6:00pm,newShift,out
100,3/1/04,6:30pm,7:30pm,mealbreak,out
100,3/1/04,10:00pm,11:30pm,newShift,out
100,3/1/03,12:00am,3am,mealbreak,out

Note: workdate = businessdate


Hope this clarified it.
 
If your interpretation of how the database is correct, then to calculate mealbreaks, I think you could use:

if {table.startreason} = "mealbreak" then {table.punchin}-previous({table.punchout})

But, I think what is confusing are the "outs" in your example below. If the employee ate from 6:00 to 6:30, what is the 7:30 out? Did they leave work again only to return at 10:00? And then leave for another mealbreak at 11:30?

empid, workdate, punchIn, punchOut, startReason, endReason
100,3/1/04,3:00pm,6:00pm,newShift,out
100,3/1/04,6:30pm,7:30pm,mealbreak,out
100,3/1/04,10:00pm,11:30pm,newShift,out
100,3/1/03,12:00am,3am,mealbreak,out

-LB
 
I don't pay attention to the "outs" since they appear to be meaningless. The app for some reason doesn't use anything more descriptive than that.

Using the previous function works for me though. THanks to all.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top