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?
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
TDateTimevalue (which is basically adouble) is very close to an integer (e.g.41029.9999999884is very close to41029) and so theVarToStrfunction assumes the decimals to be numerical fuzz.