THIS IS ABOUT FORMAT() FUNCTION AND ITS BEHAVIOR
NOT ABOUT MILLISECONDS OUTPUT!
Examples of time formatting are examples only but not more!
We have two sequential values returned by Timer(). After formatting we get rounded time measuring instead of timestamps:
? Format(36411.44921875 / 86400, "hh:nn:ss")
10:06:51
? Format(36410.984375 / 86400, "hh:nn:ss")
10:06:51 ' I'm waiting for 10:06:50 here
Add_1:
I'm not asked how to bypass this issue (like format separatly integer and decimal parts etc.). I'm interesting - is this the native behavior of Format()? Is there specific format string, for example, to avoid rounding?
Add_2:
two sequential values
Sequential is not important here. I just found mentioned behavior on this sequence by eyes in log:
222 16-10-06 10:06:51.449 36411.44921875 0.421428810402199
221 16-10-06 10:06:51.984 36410.984375 0.421423430266204
Sorry for my english...
Add_3:
In my case, I still process the integer and fractional parts separately. So I did so:
Format$(Int(dDate * 86400) / 86400, "hh:nn:ss")
'543 16-10-06 12:03:21.214 43401.21484375 0.502328875506366
'542 16-10-06 12:03:20.667 43400.66796875 0.502322545934606
However, this is just a trick and not for all cases it is convenient...
Add_4:
Apparently, my English is not good enough :(
The problem is that the use of Format() corrupts timestamp!
When taking the timestamp only rounding down is used.
For example, we have now 23:49:59.981765
What is timestamp with hours accuracy? 23. Not 00.
With minutes accuracy? Yes, 23:49, but not 23:50!
With seconds - 23:49:59.
Milliseconds? 23:49:59.981
Not to be confused with timestamps taking and time intervals measurement... In the second case, you can round off as anything... .
Add_4.1:
Playing with 23:49:59.981765 from Add_4 above:
? Format(CDate((TimeValue("23:49:59") * 86400 + .981765) / 86400), "hh")
23 ' *** !!! NOT ROUNDED !!! ***
? Format(CDate((TimeValue("23:49:59") * 86400 + .981765) / 86400), "hh:nn")
23:50
? Format(CDate((TimeValue("23:49:59") * 86400 + .981765) / 86400), "hh:nn:ss")
23:50:00
Conclusion
The Format() behaves as he likes.
Some values it rounds, some - not. By which rules? It is a top secret.
For what reason it uses standard rounding instead of bank rounding in VB(A)? It is a top secret No. 2.
.
++++++++++++++++++++++++++++++++++++++++++++++++
P.S.
First of all - many thanks to Comintern (RotFront!) and Gustav for usefull clarifying of touched problems.
However, my question (statement) - The Format() behaves as he likes - is open still.
It was my big-big mistake when I said the words "Timer()" and "Milliseconds". And even when the title was clarifying all ignored it. I ask in second time - please, forget "Timer()", "Milliseconds" and your catterpillars of digits after dot.
Really there was the only remark from Comintern (RotFront!) on which disclosure I was waited for:
The Date type itself is specified with second precision, and Format in this context works on Date types.
In other words, not Format(), but internal (im- or explicitly) convert to Date datatype is the cause of around. And I was ready to be satisfied with this, but:
A. As say https://msdn.microsoft.com/en-us/library/ms221646.aspx
The variant time resolves to one second. Any milliseconds in the input date are ignored.
We see that milliseconds not only not ignored, but rounded instead of!
B. How_1 they are rounded?
Comintern (RotFront!) is absolutelly right when say:
It is impossible to consider rounding of only a second without looking at it in context of the full time.
In my case the rounding chain breaks on the hours. But it assumed, that all of time components, i.e. seconds, minutes, hours, days, monthes, years are equitable...
C. How_2 they are rounded?
Comintern (RotFront!) wrote:
Windows uses the round half away from zero method1.
Which "Windows"? Who is "Windows"? I know, that VB(A) has a single rounding function - Round() - and it use "Round half to even". All internal rounding at data types conversion use it too. But not "half away from zero".
And only Format(), upstart, white crow, use "half away from zero"... Why?
D. Resolution_1...
And what means "resolution" applying to data type? 500 mcs, 1 sec - there are only a two-three sources where this "resolution" figures sounded... I have the Date==Double data type on the hands. I can't understand - how they can be dropped from continuous numerical line - this 0.5-1 sec...
E. Resolution_2...
Maybe all this misunderstanding is because only internal timers - Date(), Now(), Time(), Timer() - are considered as an only possible sources of timestamps? In my case I get external csv log with reliable authentic timestamps and Format() distorts this excellent data for me.
And even in case of directly Timer() using. I have two counts on display from QueryPerformanceCounter and from GetSystemTimeAsFileTime. For visually evaluate their validity I format both as "hh:nn:ss.000" and place near them Timer() data which distorted by Format()... .