Re: Reading timestamp values from Datums gives garbage values

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Reading timestamp values from Datums gives garbage values
Дата
Msg-id 3528491.1716223454@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Reading timestamp values from Datums gives garbage values  (Tomas Vondra <tomas.vondra@enterprisedb.com>)
Список pgsql-hackers
Tomas Vondra <tomas.vondra@enterprisedb.com> writes:
> On 5/20/24 16:37, Sushrut Shivaswamy wrote:
>> When trying to read the query response from the Datum, I get garbage values.
>> I've tried various types and none of them read the correct value.

> TimestampTz is int64, so using DatumGetInt64 is probably the simplest
> solution. And it's the number of microseconds, so X/1e6 should give you
> the epoch.

Don't forget that TimestampTz uses an epoch (time zero) of 2000-01-01.
If you want a Unix-convention value where the epoch is 1970-01-01,
you'll need to add 30 years to the result.

The reported values seem pretty substantially off, though ---
5293917674 would be barely an hour and a half later than the
epoch, which seems unlikely to be the value Sushrut intended
to test with.  I suspect a mistake that's outside the fragment
of code we were shown.

            regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Chapman Flack
Дата:
Сообщение: Re: Reading timestamp values from Datums gives garbage values
Следующее
От: "Jonathan S. Katz"
Дата:
Сообщение: Re: PostgreSQL 17 Beta 1 release announcement draft