c++buildertdbgridtdatetimetfield

Whats wrong with TDateTime value


I have a TDateTime variable called currMonth. currMonth's value is "6/30/2000 11:59:59 PM". I need to insert currMonth as default value for a field at TDBGrid called dtBegin.

I try this code :

dtBegin->AsDateTime = currMonth;

And the compiler is succeed compiling the project, but when I debug it, I get dtBegin value is not "6/30/2000 11:59:59 PM" but { 36738.9999999884 }.

Anyone know whats wrong with this TDateTime object?

Thanks in advance.


Solution

  • There are numerous replies to your same question that you posted on the Embarcadero forum at the same time you posted here.

    In a nutshell, there is nothing wrong at all. TDateTime is implemented as a double internally. The debug inspector is merely showing you that double value as-is, not a formatted date/time string that you are expecting. This is normal behavior, and your TDateTime itself will work fine in your code. You are using an older version of C++Builder, so you do not have the TDateTime debug visualizer that newer versions of C++Builder have for displaying TDateTime values nicer, that's all.

    If you need to see the TDateTime value in a formatted manner inside the debugger, you will have to define an entry in the Watch List that calls the RTL's DateTimeToStr() function, or the TDateTime::FormatString() method, and displays the result to you.