Re: Postgres Date Type Value - Mailing list pgsql-general

From Tom Lane
Subject Re: Postgres Date Type Value
Date
Msg-id 89384.1671322850@sss.pgh.pa.us
Whole thread Raw
In response to Postgres Date Type Value  (Michael Arnold <myk321@gmail.com>)
List pgsql-general
Michael Arnold <myk321@gmail.com> writes:
> 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.

The origin is 2000-01-01 (I'm pretty sure that's documented somewhere),
so the correct integer value for that date is 8333 by my math.

Looking at the bit-pattern for 1,466,004,328: 0x57617368, it seems
totally unrelated, more like ASCII text ("Wash") than anything else.
You sure you're reading the right column of the result?

            regards, tom lane



pgsql-general by date:

Previous
From: Michael Arnold
Date:
Subject: Postgres Date Type Value
Next
From: "David G. Johnston"
Date:
Subject: Re: Postgres Date Type Value