I'm trying to get the elapsed times in miliseconds in windows. The only way I've found to do this is to get the number of 100 nanoseconds since 1601 with the FILETIME structure. But the FILETIME structure stores the value in two variables, and I want to know how I can substract two of this structures, divide them by 10000 (to get the miliseconds) and store the result in a single variable I'm using c++ with visual studio 2008 express edition
Explanation: To subtract time, subtract the minutes then subtract the hours. Since we can't have negative minutes, add 60 to the minutes and subtract 1 from the hours (60 minutes = 1 hour).
Calculate the difference in days Select cell D2, which is the first blank cell in the Duration column. Type =C2-B2, and then press RETURN . Excel displays the result as the number of days between the two dates (104). Select cell D2.
Calculate the duration between two times First, identify the starting and an ending time. The goal is to subtract the starting time from the ending time under the correct conditions. If the times are not already in 24-hour time, convert them to 24-hour time. AM hours are the same in both 12-hour and 24-hour time.
Read the documentation of FILETIME
:
It is not recommended that you add and subtract values from the FILETIME structure to obtain relative times. Instead, you should copy the low- and high-order parts of the file time to a ULARGE_INTEGER structure, perform 64-bit arithmetic on the QuadPart member, and copy the LowPart and HighPart members into the FILETIME structure.
And there you have your single number, too (QuadPart
of the ULARGE_INTEGER
structure).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With