Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Compute difference between two times
Message
From
08/06/2004 09:01:15
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
08/06/2004 04:45:37
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00911027
Message ID:
00911128
Views:
13
>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)
Previous
Reply
Map
View

Click here to load this message in the networking platform