Page 1 of 1

TUniquery Parameter text is different to value?

Posted: Mon 06 Jun 2016 08:24
by JoelH
I have a question about the text and value of a TUniqueryParameter.

I have the following code to fill the Parameter of a TUniquery:

Code: Select all

if (aFieldType in [ftDate,ftDateTime]) then
      begin
           Params.items[iParam].DataType := aFieldType;
           if (varisnull(Daten[icol, irow]))
           or (varisempty(Daten[icol,irow]))
           or (length(trim(vartostr(Daten[icol,irow]))) = 0) then
               Params.items[iparam].value := NULL
           else
               Params.items[iparam].Value := formatDateTime('dd.mm.yyyy hh:nn:ss',strtodatetime(Daten[icol,irow]));
in my case the Fieldtype is ftDateTime and the Value is set to (for today) '06.06.2016 00:00:00'

but if i let me show Params.items[iparam].text in the Debugger i receive '31.12.1899' .

My simple question, is why are text and value different?

Re: TUniquery Parameter text is different to value?

Posted: Tue 07 Jun 2016 08:24
by MaximG
The '31.12.1899' value is correct in this case. You can make this sure using a simple code abstract :

Code: Select all

var
  myParam: TParam;
begin
  myParam := TParam.Create(Nil);
  try
    myParam.Value := Null;
    ShowMessage(myParam.Text);
    ShowMessage(DateTimeToStr(myParam.AsDateTime));
  finally
    myParam.Free;
  end;
end;