[Solved] what am I missing in this datetostr conversion? [closed]


You are declaring a TDateTime variable:

var
  myDate : TDateTime;

You are then trying to assign to this variable the result of a function that converts a TDateTime to a String:

myDate := datetimetostr(dxDateTimeWheelPicker2.DateTime);

So of course you get an incompatible types error, because a TDateTime is not assignment compatible with a String. But for this exercise you only need the TDateTime value itself so this intermediate string conversion is entirely unnecessary. All you need is this:

myDate := dxDateTimeWheelPicker2.DateTime;
label1.Caption := formatdatetime('mm', myDate);

In this case you could even do without the myDate variable itself if you wished:

label1.Caption := formatdatetime('mm', dxDateTimeWheelPicker2.DateTime);

solved what am I missing in this datetostr conversion? [closed]