Bad conversion from EndOfTheMonth(date) to Variant value
datetime, delphi, delphi-xe2, rounding, variant
Solution
ShowMessage(DateTimeToStr(data) + ' vs ' + DateTimeToStr(VarToDateTime(V)));
Update: I would guess the problem is that the last millisecond of the month is very close to 0:00:00 the next day, that is, the `TDateTime` value (which is basically a `double`) is very close to an integer (e.g. `41029.9999999884` is very close to `41029`) and so the `VarToStr` function assumes the decimals to be numerical fuzz.
Problem
I have a `TDateTime` value (that I get as result from `EndOfTheMonth(date)`) to a variant type. The result is wrongly rounded. Let's have a look at example: ``` data := EndOfTheMonth(date); V := data; ShowMessage(DateTimeToStr(data) + ' vs ' + VarToStr(V)); // output is // data = 2012-01-31 23:59:59 // v = 2012-02-01 // why next day? ``` Is it designed behaviour? How to work around this?