From: Mike Rylander <miker@n2bb.com>
To: teknokrat@yahoo.com
To: pgsql-sql@postgresql.org
Subject: Re: converting interval to timestamp
Date: Fri, 1 Aug 2003 08:41:49 -0400
Message-ID: <200308010841.50193.miker@n2bb.com> (raw)
In-Reply-To: <bgbeoe$62e$1@localhost.localdomain>
References: <bgbeoe$62e$1@localhost.localdomain>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
If the number of seconds between timestamps is acceptable then this is the
solution I use:
SELECT ABS(EXTRACT(EPOCH FROM t.field1) - EXTRACT(EPOCH FROM t.field2)) AS
diff FROM table AS t;
Adjust to your column and WHERE needs. One caveat: this only works for dates
within the UNIX epoch ( after 1969-12-31).
On Thursday 31 July 2003 12:05 pm, teknokrat wrote:
> The difference of two dates/timestamps always gives an interval. is
> there a way to convert this interval into number such as number of
> milliseconds or number of days?
>
> Also does anyone know what field type an interval would map to in jdbc?
>
> thanks
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if your
> joining column's datatypes do not match
- --
Mike Rylander
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE/KmAOgRDV1fFA+3cRAgbVAJ9B03Pxsn+N+Xg2C/a4gw3j28KSsgCeNA7+
y2rYedgRdTY/BiNSfVJTvOs=
=kVkm
-----END PGP SIGNATURE-----
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: miker@n2bb.com, teknokrat@yahoo.com
Subject: Re: converting interval to timestamp
In-Reply-To: <200308010841.50193.miker@n2bb.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