FieldIsNull does not work for dates
My objective in a report was that if a date field is null, print a blank (or <<< NULL >>> for debugging purposes) otherwise the date and time.
In my version which is the latest there is 'FastReport 2.51 Undocumented features', which mentions the FieldIsNull function for scripts.
My problem is that with dates it does not work. The logic
if FIELDISNULL([dmManagement.cdsResults."TransferredWhen"]) then
DateTransferred := '<<< Null >>>'
else
DateTransferred := FormatDateTime('dd/mm/yyyy hh:mm:ss',[dmManagement.cdsResults."TransferredWhen"]);
Returns with every date being NULL.
My work around is to use this logic
DateTransferred := FormatDateTime('dd/mm/yyyy hh:mm:ss',[dmManagement.cdsResults."TransferredWhen"]);
if DateTransferred = '30/12/1899 00:00:00' then DateTransferred := '<< NULL >>'
The other interesting thing is that I use the text memo editor to insert a date field, I get a value of zero displayed rather than the usual null date value of
30/12/1899 00:00:00.
If I use the designer to add a date field to a band it works ok.
I am using ADO via clientdatasets if that is causing any upsets.
In my version which is the latest there is 'FastReport 2.51 Undocumented features', which mentions the FieldIsNull function for scripts.
My problem is that with dates it does not work. The logic
if FIELDISNULL([dmManagement.cdsResults."TransferredWhen"]) then
DateTransferred := '<<< Null >>>'
else
DateTransferred := FormatDateTime('dd/mm/yyyy hh:mm:ss',[dmManagement.cdsResults."TransferredWhen"]);
Returns with every date being NULL.
My work around is to use this logic
DateTransferred := FormatDateTime('dd/mm/yyyy hh:mm:ss',[dmManagement.cdsResults."TransferredWhen"]);
if DateTransferred = '30/12/1899 00:00:00' then DateTransferred := '<< NULL >>'
The other interesting thing is that I use the text memo editor to insert a date field, I get a value of zero displayed rather than the usual null date value of
30/12/1899 00:00:00.
If I use the designer to add a date field to a band it works ok.
I am using ADO via clientdatasets if that is causing any upsets.
Comments
Regards:Alex
However I added the extra quotes but it still does not work. Everthing is still
reported as a null. Using two different date fields, I have reported each field three times in the same report, as it comes from the database, using the FieldIsNull function and
using the formatdatetime function and checking for 30/12/1899.
The FieldIsNull always reports it as null.
I can send you a prepared report if you like and the frf file.
(which matches thwe documentation)
if FIELDISNULL('[dmManagement.cdsResults."TransferredWhen"]') then
Date1A := '<<< Null >>>'
else
Date1A := FormatDateTime('dd/mm/yyyy hh:mm:ss',[dmManagement.cdsResults."TransferredWhen"]);
if (FIELDISNULL('[dmManagement.cdsResults."TransferredWhen"]')) then
Date1A := '<<< Null >>>'
else
Date1A := FormatDateTime('dd/mm/yyyy hh:mm:ss',[dmManagement.cdsResults."TransferredWhen"]);
and which matches your example in this post
if [(FIELDISNULL('[dmManagement.cdsResults."TransferredWhen"]'))] then
Date1A := '<<< Null >>>'
else
Date1A := FormatDateTime('dd/mm/yyyy hh:mm:ss',[dmManagement.cdsResults."TransferredWhen"]);
However I only get null every time.
try this syntax sub your own values as needed.
if [(FIELDISNULL('CustomerData.Customers."LastInvoiceDate"'))] then
code to set what you want...... ;
works fine for me in bde,ads.
regards