Re: Datetime

From: Michael Glaesemann <grzm(at)myrealbox(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Pedro B(dot)" <pedro(dot)borracha(at)netcabo(dot)pt>, Achilleus Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Datetime
Date: 2004-08-03 22:16:16
Message-ID: BD0DA1B6-E59A-11D8-8966-000A95C88220@myrealbox.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


On Aug 4, 2004, at 12:13 AM, Tom Lane wrote:

> Michael Glaesemann <grzm(at)myrealbox(dot)com> writes:
>> No. I'm just saying that PostgreSQL does not represent or store
>> timestamps as epoch timestamps internally.
>
> You're wrong.
>
> It's not exactly Unix-like because we use a different epoch date
> (2000-1-1 not 1970-1-1) but the concept is just the same: what's
> stored is the number of seconds before or after the epoch. The
> default is to store this as a double precision number (hence supporting
> fractional seconds, with a machine-dependent amount of precision)
> but you can compile the server to use 64-bit integers instead. In that
> case the integer value actually represents microseconds before or after
> the epoch, and so the precision is fixed at microseconds.

As I understood Achilleus, he said that PostgreSQL used UNIX epoch
timestamp internally, which is defined as seconds from 1970-01-01. What
I said is that PostgreSQL does not use UNIX epoch internally, which is
exactly what you've verified. PostgreSQL uses seconds and microseconds
from 2000-01-01, and PostgreSQL can be compiled to use 64-bit integers
(rather than double precision floats) to represent integer microseconds
from 2000-01-01. Thank you for explaining these things. However, I
don't quite understand how I am wrong in saying that PostgreSQL does
not use UNIX epoch timestamps internally, as you've clearly explained
it doesn't.

> What you see when you display the value is an external textual
> representation, not the internal form.

Which I don't think was ever at issue.

Thanks again for explaining the internals. I'm trying to learn as much
as I can grepping the source, but it's often easier to hear an
explanation.

Michael Glaesemann
grzm myrealbox com

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2004-08-03 22:55:08 Re: Datetime
Previous Message Tom Lane 2004-08-03 15:13:29 Re: Datetime