Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Tore Bleken
  Where is Tore Bleken?
 Stokke
 Norway
 Tore Bleken
 To: Shaheryar Rashed
  Where is Shaheryar Rashed?
 Multan
 Pakistan
 Shaheryar Rashed
 Tags
Subject: RE: time totals
Thread ID: 395497 Message ID: 395508 # Views: 42 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Forms
Date: Wednesday, January 15, 2014 3:22:29 PM         
   


> >
> >
> > nhour=0
> > scan 
> >   nhour=nhour+val(substr(tablename.lastcolumn,1,2)+val(substr(tablename.lastcolumn,4,2)) / 60  && or without dividing with 60 ??
> > endscan   && I can't guess if you have to present them in just hours + fraction or hours + minutes
> > 

> > .CMIIW whereever, that's just the idea
>
> Sir, i changed data as below kindly check it and correct it
>
Create Cursor test ( ariv c(10), dis c(10) )
> Create Cursor t2 ( ariv c(10), dis c(10), labour c(10), part1 c(10), part2 c(10))
> Create Cursor t3 (hour1 N(12), minut1 n(12))
> 
> Insert into test values ('08:00a', '08:30p')
> Insert into test values ('08:00a', '09:40p')
> Insert into test values ('08:00a', '10:45p')
> 
> SELECT test
> SCAN
> 	SELECT t2
> 	APPEND BLANK
> 	REPLACE t2.ariv WITH test.ariv, t2.dis WITH test.dis, t2.labour WITH ;
> 			Transform( Right( Ttoc( Ctot(test.dis) - ( Ctot(test.ariv) - Ctot('0')), 1 ), 6), '@R 99:99' ) IN t2
> 	LOCAL lcLBR
> 			lcLBR = ALLTRIM(t2.labour)
> 	REPLACE part1 WITH ALLTRIM(left(lcLBR,2)), part2 WITH ALLTRIM(right(LcLBR,2))		
> 	ENDSCAN
> SELECT t2
> brow
> 
> 
> SELECT t2
> SUM VAL((t2.part1)) TO lnJ1
> lnJ1 = lnJ1*60
> SUM VAL((t2.part2)) TO lnJ2
> IF lnJ2 => 60
> 	lnJ3 = lnJ2-60
> 	lnJ2 = 00
> endif	
> SELECT t3
> APPEND blank
> REPLACE t3.hour1 WITH (lnJ1+lnJ3)/60, t3.minut1 WITH lnj2
> brow
> 


I just want to comment on your Append Blank followed by Replace. Insert Into is both quicker and safer. Safer in the meaning that in a multi user scenario, someone else may actually change the date between the two lines. You may also get a record locking conflict. This won't happen with Insert Into. Plus, as I mentioned, it's quicker.

If you use SuperBrowse which comes with Thor, it can create most of the Insert statement for you.

There's a fine line between helping and adding to the confusion.

How to create sample data

ENTIRE THREAD

time totals Posted by Shaheryar Rashed @ 1/15/2014 1:58:56 PM
RE: time totals Posted by David Mustakim @ 1/15/2014 2:18:45 PM
RE: time totals Posted by Shaheryar Rashed @ 1/15/2014 2:30:23 PM
RE: time totals Posted by David Mustakim @ 1/15/2014 2:47:42 PM
RE: time totals Posted by Shaheryar Rashed @ 1/15/2014 3:13:41 PM
RE: time totals Posted by Tore Bleken @ 1/15/2014 3:22:29 PM
RE: time totals Posted by Shaheryar Rashed @ 1/16/2014 7:36:37 AM
RE: time totals Posted by Anders Altberg @ 1/15/2014 4:51:39 PM
RE: time totals Posted by Cetin Basoz @ 1/15/2014 5:51:36 PM
RE: time totals Posted by Shaheryar Rashed @ 1/17/2014 6:51:16 AM
RE: time totals Posted by Cetin Basoz @ 1/17/2014 1:24:20 PM
RE: time totals Posted by Shaheryar Rashed @ 1/18/2014 6:45:09 AM
RE: time totals Posted by Anders Altberg @ 1/18/2014 11:50:19 PM