pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Glaesemann <grzm@myrealbox.com>
To: Achilleus Mantzios <achill@matrix.gatewaynet.com>
Cc: Pedro B. <pedro.borracha@netcabo.pt>
Cc: pgsql-sql@postgresql.org
Subject: Re: Datetime
Date: Tue, 3 Aug 2004 20:31:11 +0900
Message-ID: <9F40F448-E540-11D8-8966-000A95C88220@myrealbox.com> (raw)
In-Reply-To: <Pine.LNX.4.44.0408031319490.7249-100000@matrix.gatewaynet.com>
References: <Pine.LNX.4.44.0408031319490.7249-100000@matrix.gatewaynet.com>


On Aug 3, 2004, at 7:23 PM, Achilleus Mantzios wrote:

> now() returns the current UNIX (your running UNIX right?) timestamp 
> which
> in turn is
> measured in seconds,miliseconds since the epoch.
> i.e. 1970-01-01 00:00:00

I believe this is incorrect. I believe PostgreSQL uses its own 
timestamp datatype internally (which is, indeed, not as text in an 
easy-to-read form). On my machine (running cvs-head),

test=# select now();
               now
-------------------------------
  2004-08-03 20:27:18.822646+09
(1 row)

which is definitely not seconds.milliseconds since epoch. You can use 
extract to get seconds.milliseconds from epoch, but I don't think this 
is how it's stored internally.

test=# select extract(epoch from now());
     date_part
-----------------
  1091532506.3222
(1 row)

Just some additional trivia, current_timestamp is an SQL-spec compliant 
alias for now(), and might be a better choice if one is concerned with 
compatibility.

Michael Glaesemann
grzm myrealbox com




view thread (11+ messages)  latest in thread

Message-ID: <9F40F448-E540-11D8-8966-000A95C88220@myrealbox.com>
Permalink:  ../9F40F448-E540-11D8-8966-000A95C88220@myrealbox.com/
Also on:    postgresql.org/message-id/9F40F448-E540-11D8-8966-000A95C88220@myrealbox.com

 · 

reply

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-sql@postgresql.org
  Cc: grzm@myrealbox.com, achill@matrix.gatewaynet.com, pedro.borracha@netcabo.pt
  Subject: Re: Datetime
  In-Reply-To: <9F40F448-E540-11D8-8966-000A95C88220@myrealbox.com>
  References: <Pine.LNX.4.44.0408031319490.7249-100000@matrix.gatewaynet.com> <9F40F448-E540-11D8-8966-000A95C88220@myrealbox.com>

* 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