Compare field type SqlTimeStamp

1

I have a question here ... I have a field in SQL Server database of type DateTime that can be null. In Delphi, inside MemTable (or ClientDataSet ... would be the same in this case), the field was created as SQLTimeStamp Field. I want to see if this field has a date or is null, but I did not get a correct comparison without giving compile error saying that the types are different. Here is the code:

if fDm.fdmEmail.FieldByName('esr_ultimo').AsSQLTimeStamp > 0 then // Aqui dá erro na compilação
begin
  // Formatar o campo...
  edtUltimo.Text := SQLTimeStampToStr('dd/mm/yyyy', fDm.fdmEmail.FieldByName('esr_ultimo').AsSQLTimeStamp);
end;

I've tried "< > NULL", "< > 'NULL'", and several others ... Thanks in advance.

    
asked by anonymous 07.07.2016 / 03:41

2 answers

1

Try to use .AsDateTime instead of .AsSQLTimeStamp , and tell whether the result was positive.

    
08.07.2016 / 13:09
0

You can use the IsNull property, it would look like this:

fDm.fdmEmail.FieldByName('esr_ultimo').IsNull;

This property returns true / false.

    
08.07.2016 / 19:44