Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: MySQL, FireDAC TDateTime



Permlink Replies: 1 - Last Post: Mar 21, 2016 1:34 AM Last Post By: Robert Triest
Jim Sawyer

Posts: 214
Registered: 1/3/10
MySQL, FireDAC TDateTime
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 20, 2016 7:48 PM
I have a variable which represents a MySQL Date. Sometimes I want to
specify that there is no date available for that variable. For this condition,
I don't know specify the value of the variable. I tried setting it to NULL,
but I get a run-time error. How should I specify this?

Thanks,
Jim Sawyer
Robert Triest

Posts: 687
Registered: 3/24/05
Re: MySQL, FireDAC TDateTime
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 21, 2016 1:34 AM   in response to: Jim Sawyer in response to: Jim Sawyer
TDateTime is an integer that starts at 0 (zero) and represents 12/30/1899 12:00 am
and a negative value will represent a date before that.

If you asks the database for a DatTime field and the field is still NULL then
the database functions will return 0 (FieldByName('MyDateField').asDateTime;

When you can't use the 0 value as an empty (NULL) indicator, like you need also
historical dates before 1899. You should filter the dates in your SQL query.

"Where MyDateField is not NULL"
or
"Where MyDateField is NULL"
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02