Subject Re: [firebird-support] Casting as timestamp for dates prior to 30 December 1899
Author Helen Borrie
Friday, November 4, 2016, 7:20:54 PM, Steve White wrote:


> select cast('29-DEC-1899 23:59:59' as timestamp) from rdb$database returns ‘30/12/1899 12:00:01 AM’

>

> select cast('29-DEC-1899 00:00:01' as timestamp) from rdb$database returns ‘30/12/1899 11:59:59 PM’

>

> Any date prior to 30 December 1899 behaves in a similar way:

>

> select cast('15-JUN-1832 9:14:21' as timestamp) from rdb$database returns ‘16/06/1832 2:45:39 PM’

>

> Looks like two whole days are added and then the time component is
> being subtracted. Works correctly after 30 December 1899. Is this a
> known issue or am I doing something I shouldn’t?

I'm guessing you are doing these tests with a Delphi application. I
can't remember the exact reason why Delphi's rendering of timestamp
as DateTime does this but the curiosity has always been there. Someone
else might remember. Using a Delphi interface, w. Fb 2.5.6 w. Dialect
3, I still get curious results which are slightly different to yours
(although the 1832 example produces the same result as yours).

In isql:

Database: emp, User: sysdba
SQL> select cast('29-DEC-1899 23:59:59' as timestamp) from rdb$database;

CAST
=========================
1899-12-29 23:59:59.0000

SQL> select cast('29-DEC-1899 00:00:01' as timestamp) from rdb$database;

CAST
=========================
1899-12-29 00:00:01.0000

SQL> select cast('15-JUN-1832 9:14:21' as timestamp) from rdb$database;

CAST
=========================
1832-06-15 09:14:21.0000

Helen