Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calculate time total
Message
De
11/06/2001 19:26:33
 
 
À
11/06/2001 18:47:14
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00518132
Message ID:
00518148
Vues:
12
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform