Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Empty Date Is 01/01/1970?
Mon, Jun 18 2018 12:12 AMPermanent Link

Frederick Chin

When a date field is NULL in a DBISAM table, storing it to the date field of another table, results in the target date field having a value of 01/01/1970.

For example,

targetDS.Columns['date'].asDateTime:=sourceDS.Columns['date'].asDateTime;

Is it possible to have the target field to also have a NULL value or a date of 31/12/1899 like Delphi?

In Delphi, I normally clear the field if the date is earlier than 01/01/1900 but in EWB, I can't apply the same logic because 01/01/1970 may be a valid date.

--
Frederick
Mon, Jun 18 2018 2:53 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Frederick,

<< When a date field is NULL in a DBISAM table, storing it to the date field of another table, results in the target date field having a value of 01/01/1970.

For example,

targetDS.Columns['date'].asDateTime:=sourceDS.Columns['date'].asDateTime;

Is it possible to have the target field to also have a NULL value or a date of 31/12/1899 like Delphi? >>

Sure, but you'll have to check for it and call Clear on the target dataset's column so that it also becomes NULL, like this:

if sourceDS.Columns['date'].Null then
targetDS.Columns['date'].Clear
else
targetDS.Columns['date'].asDateTime:=sourceDS.Columns['date'].asDateTime;

However, I think I need to add an Assign method for the TDataColumn class, otherwise this could get a little verbose over time.

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Jun 18 2018 9:02 PMPermanent Link

Frederick Chin

Tim,

/*
Sure, but you'll have to check for it and call Clear on the target dataset's column so that it also becomes NULL, like this:

if sourceDS.Columns['date'].Null then
targetDS.Columns['date'].Clear
else
targetDS.Columns['date'].asDateTime:=sourceDS.Columns['date'].asDateTime;
*/

I store the value for the sourceDS into a variable and pass it to a procedure but the value of the variable is set to 01/01/1970 when the source field is null.

If possible, I would like the value to be set by EWB to 31/12/1899 (like in Delphi) if a null field is detected, like

varDate:=sourceDS.Columns['date'].asDateTime;   // Should be 31/12/1899 and not 01/01/1970 if field is null

so that I can use the code below:-

if varDate>StrToDate('31/12/1899') then
  targetDS.Columns['date'].asDateTime:=varDate
else
  // Do nothing

--
Frederick
Fri, Jun 22 2018 4:01 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Frederick,

<< If possible, I would like the value to be set by EWB to 31/12/1899 (like in Delphi) if a null field is detected, like >>

It *will* be once it cross the network connection and lands in some Delphi code on the web server side.  What you're looking at is a peculiarity of the differences between a "zero" date/time in JS vs. a "zero" date/time in Delphi.

Tim Young
Elevate Software
www.elevatesoft.com
Image