Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calculate time total
Message
From
11/06/2001 19:26:33
 
 
To
11/06/2001 18:47:14
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00518132
Message ID:
00518148
Views:
11
>Hi
> I have a table with 2 fields one is a name, the other is a character type that contains something like this 00:02'23 which mean that this person talked on the phone for 2 minutes and 23 seconds, now I want to know is a sum of how long every person talked on the phone can anybody help

Create a function to convert to decimal hours, then use it in a SELECT - SQL to get the totals:
FUNCTION StringTimeToDecimalHours

LPARAMETERS ;
	tcStringTime

RETURN (3600 * VAL(SUBSTR(tcStringTime, 1, 2)) + ;
60 * VAL(SUBSTR(tcStringTime, 4, 2)) + ;
VAL(SUBSTR(tcStringTime, 7, 2))) / 3600

SELECT ;
	cPersonName, ;
	SUM(StringTimeToDecimalHours(cStringTimeField)) AS nHours ;
	FROM MyTable ;
	INTO CURSOR Results ;
	GROUP BY cPersonName
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Reply
Map
View

Click here to load this message in the networking platform