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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to add up minutes. CR11, MSSQL 1

Status
Not open for further replies.

azoe

Technical User
Feb 21, 2005
175
US
My report is grouped by Employee and then by day and then by appointment Type. The detail after that is appointment times in 5 minute increments like this.

Employee1
03-20-2006
NewAppointments
8:00
8:05
8:10
10:00
10:05
EstablishedAppts
01:00
01:05

What I want to do is total minutes per appointment type. so NewAppointments would be 15 minutes and Established Appts is 5 minutes.

I know how to reset a variable at the group level but I'm not sure how to do it in the detail level. Or is there another way?
Thank you -
 
A tad vague, but you can certainly use variables to add up minutes, as in:

In the Appointment type Group Header:
whileprintingrecords;
numbervar New:=0;
numbervar Estab:=0;

Details:
whileprintingrecords;
numbervar New;
numbervar Estab;
if {table.field} = "New" then
New:=New +15
else
if {table.field} = "Estabished" then
Estab:=Estab +15

In the Appointment type Group Footer (where you display the results):
whileprintingrecords;
numbervar New;
numbervar Estab;
"We had " & totext(New,0,"") & " new minutes and " & totext(estab,0,"") & " established minutes."

Generally it's best to post technical information rather than trying to describe technical information:

Example data
Expected output

-k

-k
 
Not sure if this is enough technical info but here goes:

In group header 3:
@resetTime
whileprintingrecords;
numbervar time := 0;

In Detail:
@AccumTime
whileprintingrecords;
numbervar time;
(
time := time + {@ThisTimeMinusPrevious}
);

In Group footer 3:
whileprintingrecords;
numbervar time;


Example data for group 1 is: Employee1, Employee2, etc.
Group 2: New Appointments, Established Appointments, Consultations, etc.
Group 3: 03/20/2006, 03/21/2006, etc.
Detail: 8:00, 8:05, 8:10, 10:00, 10:05, 13:00 (instead of 1:00 as shown in first post), 13:05, 16:00, 16:05, 16:10, etc.

The problem is that I want to reset the variable if there is more than 5 minutes between the times. I'm counting minutes still available in the day. Appointments after 8:10 and before 10:00 are already taken.
In the example the time jumps from 8:10 to 10:00 but I don't want to count the time in between those two. I want to count the time between 8:00 and 8:10 but then start over at 10:00 and then if possible get a total for group 3.

Expected output:
Employee1
3-20-2006
NewAppointments 15 minutes
EstablishedAppts 5 minutes

Appointment slots (times) in the database stored separately from dates as Char(4).

{@ThisTimeMinusPrevious} =
tonumber({aa_OpenTime;1.BeginTime}) - tonumber(Previous({aa_OpenTime;1.BeginTime}))
Thanks
 
I don't see how the 15 and 5 minutes are derived, your detail is thew same for every group???

Why not display data as it is stored instead of jamming it all together and expecting us to know which is for which grouping:

group 1 Employee1
Group 2: New Appointments
Group 3: 03/20/2006
Detail: 8:00, 8:05, 8:10, 10:00, 10:05, 13:00, 13:05, 16:00, 16:05, 16:10

And state what you are counting, what you are not, and the expected output.

-k
 
Try changing your formula to:

//{@AccumTime}:
whileprintingrecords;
numbervar time;

if {@ThisTimeMinusPrevious} <= 5 then
time := time + {@ThisTimeMinusPrevious};

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top