Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Date & Time Calculation
Message
From
26/12/1999 12:28:23
 
 
To
26/12/1999 10:50:50
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00308627
Message ID:
00308635
Views:
17
>Could anyone enlighten me on which is a better way
>to calculate the differences in 2 given times?
>
>Eg: 08:30 to 17:30 how to apply a formula that
>would calculate the difference is 9 hours? Thanks

If they're stored in DateTime formats, just subtract them; the difference is the difference in seconds (there's an issue with rounding that might vary by +/-1 second; taking the INT() of the difference before assigning the value seems to be a good workaround. There's information on this in the current issue of FoxPro Advisor.) Once you have a difference in seconds, it's trivial to convert to another measure of time by simple division; if the difference is not needed for computational purposes (in which case you need a numeric value IAC) and is < 1 day, the foillowing extracts the time string:

TTOC(DTOT(DATE() + nDiffInSeconds),2)

The string returns in accordance with the current SET conditions; see the VFP docs for the effects.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform