In a message dated 9/3/2007 6:38:18 P.M. Central Daylight Time, [EMAIL PROTECTED] writes: >As I understand TOD time is the number of mic seconds elapsed since midnight of 1900-01-01. Partially correct. Bit 51 of the 64-bit TOD clock is the number of microseconds since... etc. But there are 12 more bits to the right of bit 51, so the right-most bit of the 8-byte TOD clock is 4096 times the number of microseconds since... etc. >So when I subtract one TOD value from another the duration must be in micro seconds. For example, TOD1 is X'C0E608EF7409002E' ===>2007196, 16.59.58,745744 TOD2 is X'C1E608EF7409002E' ====> 2008035, 7.43.04.790160 >If I subtract the two TOD values, it is binary as in (x'0100000000000000'). If I convert to a packed decimal value, I get a decimal value of 72057594037927936. (sign bit not shown here) >Now I can't seem to figure the actual elapsed time based on the derived micro seconds. If I just treat the above value as a mic seconds then I end up with 2284.93 years which is gloriously incorrect while the actual elapsed days are 204 days ignoring the time part. Divide that decimal number by 4096, and you will have the number of microseconds in the interval. Since your original interval in hexadecimal (what you call binary) ends in a long string of zeroes, a simple, exact way to divide by 4096 is to remove the right-most three zeroes. And since one million microseconds = one second, and since one million is very close to two to the 20th power (or 16 to the 5th), you can approximate the number of seconds in the interval by removing 5 more of the right-most zeroes (each zero = another power of 16). This is probably not accurate enough for your real work, but it will give you a quick reality check on your math. After removing a total of eight zeroes from the right end, you are left with X'01000000', which is the number of microseconds in your interval. This is equal to ca. 16 million seconds (I am rounding off some more), which is ca. 185.2 days. After all the rounding off I did, I claim that my math passes my reality check. Do it all again with no rounding and you should get your answer of 204 days.
Bill Fairchild Plainfield, IL ************************************** Get a sneak peek of the all-new AOL at http://discover.aol.com/memed/aolcom30tour ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO Search the archives at http://bama.ua.edu/archives/ibm-main.html