#1 2022-08-30 22:16:05

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 430

Is a Tdate property allowed in a TOrm object?

I just notice that if a TOrm derived object has a property of type Tdate then when adding-saving it in the database (mariadb) through zeos I am getting crazy dates in the future.
For example 21-07-1975 is transformed in the insert query as '2759-01-01'
If I change the property to Tdatetime type, the date in the sql query is shown ok ('1975-07-21')
In the database it is created as Date field.

I noticed that in TOrm.AppendAsJsonObject a Tdatetime property is going through TOrmPropInfoRttiDateTime.GetJsonValues and TTextDateWriter.AddDateTime.  In contrast, a Tdate property is going through TOrmPropInfoRttiDouble.GetJsonValues

Are Tdate type valid for Torm properties?

Thank you in advance

Offline

#2 2022-08-31 17:38:36

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Is a Tdate property allowed in a TOrm object?

Did you try with TDateTime?

Offline

#3 2022-08-31 17:44:34

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 430

Re: Is a Tdate property allowed in a TOrm object?

ab wrote:

Did you try with TDateTime?

With Tdatetime, as I wrote, there is no problem

Offline

#4 2022-08-31 19:24:34

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Is a Tdate property allowed in a TOrm object?

So yes, TDate is not supported.
It sounds like if a plain TDate is just like a plain double, so work with the ORM and/or ZDBC is consistent.

It is documented as such IIRC.
At least, only TDateTime and TDateTimeMS are documented to be properly supported by our ORM and our DB layer.

Offline

Board footer

Powered by FluxBB