 Forum List • Thread List • Refresh • New Topic • Search • Previous • Next 1  1. From hex string to date? #6598 Posted by: 20050826 14:29:32  I have an hexadecimal string representing microseconds elapsed since AD 0; how can I convert it to current Date? Does it exist a readymade RapidQ source? I probably could convert that string to another string representing seconds elapsed since 1/1/1970, which is a more commonly used format,but I still have the problem of messing with leap yeras, differentlength months and so on...
Example of "0 AD"based string: 00E0D1E0F6FB1DDE = [20050419 19:42:09] see http://orefa.com/addup/2/ , use this string to convert: '[] (16'00E0D1E0F6FB1DDE)/1000000
Same string, 1970based: 3FB50ED94AD12 (= decimal 70046870751953)
How can I obtain [20050419 19:42:09] from this mess of numbers?!?  2. Re: From hex string to date? #6700 Posted by: 20050903 08:20:40  1.start by converting the whole string to a decimal format AND dividing by 1000 (you only want whole seconds), save the resulting value (let's call it DT)
2. divide the result by 31557600 and round off to get the year
3. DT  year*31557600 gives you a remainder (call it PY)
4. the remainder of PY / 60 gives you the seconds (S)
5. the remainder of (PY  S) / 60 gives minutes (M)
6. the remainder of (PY  M*60  S)/3600 gives hours
7. calculate the number of whole days left over (WD). Use an array with the days of the months summed (adding 1 day to the total for MARCH  first day of  in a leapyear) to quickly find the month by going DOWN the array and subtracting the total from WD; if there is a positive result (>0) you've found the month. The leftover is the day of the month.  3. Re: From hex string to date? #6701 Posted by: 20050903 08:26:13  on leapyears; every 4th year is a leapyear, every 100th year is NOT a leapyear, every 400th year IS a leapyear.
the value 31557600 is slightly off I'm afraid, as its just 365.25 x 24 x 60 x 60, instead of 365.25 you have to use a SLIGHTLY different value; 365.2422
so use 31556926.08 instead of 31557600 !!!  Forum List • Thread List • Refresh • New Topic • Search • Previous • Next 1 

