Question : Collect Records then Scan Through to Store Times

so I SQLCONNECT() and get my data I need from the AS400
I have it load into a cursor....

date, user, item,Qty,  cust, ord, startTime, EndTime...

so I get it all for a day nto cursor, now I need to group by customer (so I can go through and count the lines and see the time from starEndt and endTime)

I think I would need to:
 SELECT MyCursor
SCAN
Do While !EOF()
store startTime to m.StartTime
store EndTime to m.EndTime
Next
EndDo


*-- Now do the math to calculate each customer's time it took to pull
...?


then I can get it to calculate the time it took for each customer..?


Answer : Collect Records then Scan Through to Store Times

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
SELECT MyCursor
SCAN
    REPLACE time WITH hoursdif(StartTime, EndTime)
ENDSCAN

FUNCTION hoursdif
PARAMETER m.time1, m.time2
PRIVATE m.time1, m.time2, m.difhours, m.difminutes
IF m.time1 > m.time2
	m.difhours = VAL(LEFT(m.time1,2)) - VAL(LEFT(m.time2,2))
	m.difminutes = VAL(RIGHT(m.time1,2)) - VAL(RIGHT(m.time2,2))
ELSE
	m.difhours = VAL(LEFT(m.time2,2)) - VAL(LEFT(m.time1,2))
	m.difminutes = VAL(RIGHT(m.time2,2)) - VAL(RIGHT(m.time1,2))
ENDIF
DO WHILE m.difminutes < 0
	m.difminutes = m.difminutes + 60
	m.difhours = m.difhours - 1
ENDDO
IF m.difhours = 0 AND m.difminutes = 0
	RETURN '     '
ELSE
	RETURN STRTRAN(STR(m.difhours,2) + ':' + STR(m.difminutes,2),' ','0')
ENDIF
Random Solutions  
 
programming4us programming4us