1
I have a question here... I have a field in the SQL Server database of the type Datetime that can be null. In Delphi, within the Memtable (or Clientdataset... would be the same thing in my case), the field was created as Sqltimestamp Field. I want to see if this field has a date or is null, but I didn’t get a correct comparison without giving compilation error saying that the types are different. Follows 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.
Try to use the
.AsDateTime
instead of.AsSQLTimeStamp
, and tell if the result was positive.– Victor Tadashi
Victor, it worked. When formatting the date for the Edit field I also used "Asdatetime" and the "Formatdatetime" function to format it correctly. Thank you!
– Rodrigo Tognin
Could turn comment into reply?
– Victor Tadashi
Sorry, I’m new around here... how do I do it?
– Rodrigo Tognin
I’m not sure how either. but I believe that I have this option, take a look: http://meta.pt.stackoverflow.com/questions/2333/por-que-muitas-peoples-respond-nos-coment%C3%A1rios-em-vez-de-criar-uma-resposta/2334#2334
– Victor Tadashi
For mi nothing appears that allows me to do this. I think I need to have more scores so I can turn comments into answers...
– Rodrigo Tognin