Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Compute difference between two times
Message
De
08/06/2004 09:01:15
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
08/06/2004 04:45:37
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00911027
Message ID:
00911128
Vues:
11
>pls help me i'm confused.
>
>i'm trying to get the difference between two times (7:42AM and 12:16PM). in my program i do,
>
>
>((12-7)*60)+abs(42-16)
>
You have to subtract right minus left in both cases. Also, you don't have to use abs(); 16 - 42 should give you a negative number, so that it will be subtracted from the hours. (Adding a negative number is the same as subtracting a positive number; this is called "algebraic addition".)

So, for your example, your expression should simply be:


? ((12-7)*60)+(16-42)


Some parentheses are unnecessary for the calculation, although they may help for clarity. Anyway, your expression might also be:
? (12-7)*60 + 16-42
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform