From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Arnold <myk321@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Postgres Date Type Value
Date: Sat, 17 Dec 2022 19:20:50 -0500
Message-ID: <89384.1671322850@sss.pgh.pa.us> (raw)
In-Reply-To: <CAMOVWRiUuVQ6hHqAFSmnto3JQ2LRCu6jGmSYL_jvN7FXic=jbg@mail.gmail.com>
References: <CAMOVWRiUuVQ6hHqAFSmnto3JQ2LRCu6jGmSYL_jvN7FXic=jbg@mail.gmail.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, myk321@gmail.com
Subject: Re: Postgres Date Type Value
In-Reply-To: <89384.1671322850@sss.pgh.pa.us>
References: <CAMOVWRiUuVQ6hHqAFSmnto3JQ2LRCu6jGmSYL_jvN7FXic=jbg@mail.gmail.com> <89384.1671322850@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox