Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p6hQM-0003Ok-8J for pgsql-general@arkaria.postgresql.org; Sun, 18 Dec 2022 00:21:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p6hQK-0002Vs-JN for pgsql-general@arkaria.postgresql.org; Sun, 18 Dec 2022 00:21:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p6hQK-0002Vh-9D for pgsql-general@lists.postgresql.org; Sun, 18 Dec 2022 00:21:00 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p6hQD-000330-CD for pgsql-general@lists.postgresql.org; Sun, 18 Dec 2022 00:20:58 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 2BI0Koss089385; Sat, 17 Dec 2022 19:20:50 -0500 From: Tom Lane To: Michael Arnold cc: pgsql-general@lists.postgresql.org Subject: Re: Postgres Date Type Value In-reply-to: References: Comments: In-reply-to Michael Arnold message dated "Sun, 18 Dec 2022 07:55:16 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <89383.1671322850.1@sss.pgh.pa.us> Date: Sat, 17 Dec 2022 19:20:50 -0500 Message-ID: <89384.1671322850@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Michael Arnold 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