Page 1 of 1

Postgres / TDateTime

Posted: Tue 27 Apr 2021 06:03
by bursch
Hello,

under Postgres, very small date values (<01.01.0100) are always set to the value MinDateTime. TimeStamp values, on the other hand, work without problems.

Very small values can lead to inaccuracies, but there is no reason for this restriction. The Postgres database supports values from 4713BC.

Since there is no need for this restriction for timestamp values and this is also interpreted as TDateTime, it would only be logical to remove this restriction.

Code: Select all

unit PGClassesUni;

(...)

class procedure TPgBinaryConverter.ReadDate(Source: TPgSQLNet; Dest: IntPtr);
At least the date 01/01/0000 should still be possible.

Greetings,
Manuel

Re: Postgres / TDateTime

Posted: Thu 13 May 2021 14:15
by MaximG
Our components don't impose this restriction. The minimum and maximum values for ftDateTime are defined in Delphi on the base level, we're not able to change them.
You'll get the same results in standard Delphi data access components. You may create a table DATE_TYPES in pgAdmin

Code: Select all

CREATE TABLE DATE_TYPES (ID SERIAL,  F_DATE DATE, PRIMARY KEY (ID));
and insert a record

Code: Select all

INSERT INTO DATE_TYPES (id, f_DATE) VALUES (10, 'J0000187');
Querying the table in pgAdmin Select F_DATE From DATE_TYPES will return 4713-05-29 BC, whereas the same query executed with FireDAC components will return 01.01.0100