Postgres Date Type Value

Поиск
Список
Период
Сортировка
От Michael Arnold
Тема Postgres Date Type Value
Дата
Msg-id CAMOVWRiUuVQ6hHqAFSmnto3JQ2LRCu6jGmSYL_jvN7FXic=jbg@mail.gmail.com
обсуждение исходный текст
Ответы Re: Postgres Date Type Value  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Postgres Date Type Value  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-general

Want to retrieve a date type from a postgres table using libpq PQexecParams() in binary mode (please humor me). https://www.postgresql.org/docs/14/datatype-datetime.html says that a date is 4 bytes (4713 BC to 5874897 AD). src/include/utils/date.h defines:

  typedef int32 DateADT;

Something like this:

  int32_t date_val = be32toh(*((uint32_t *) PQgetvalue(res, 0, 17)));

Gives date_val=1,466,004,328 for 2022-10-25.

Since 4713BC is the start of the Julian calendar thought it might be a simple day count but the value is too large (2,459,878 days from 1 Jan 4713BC to 2022-10-25).  So clearly not a day count.  My simple maths gives me 585.966... ticks per day.

How do I interpret the 4 bytes of postgresql 'date' value?

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

Предыдущее
От: "Dan Langille"
Дата:
Сообщение: Re: tsvector not giving expected results on one host
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Postgres Date Type Value