From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: Esteban Chiner Sanz <echiner@tissat.es>
To: pgsql-sql@postgreSQL.org
Subject: Re: Max function on Timestamp
Date: Mon, 6 Sep 1999 14:37:50 +0300
Message-ID: <l03130300b3f9532becaf@[147.233.159.109]> (raw)
In-Reply-To: <37CE3592.2558E205@tissat.es>
At 11:30 +0300 on 02/09/1999, Esteban Chiner Sanz wrote:
> I have a table in my database with a timestamp field and I can't use a
> max function on it. You can do it with any other date types (date,
> timespan, etc.) but not with timestamp.
> Is there any problem on doing it? Why isn't it implemented in PostgreSQL
> 6.5.1? What would be the easiest way of doing it?
You can convert to datetime and back. I have 6.4, in which conversion from
datetime to timestamp is broken. I don't know whether or not it is broken
in 6.5.1 as well, but if it is, you can easily define:
CREATE FUNCTION dt_to_ts( datetime ) returns timestamp
AS 'SELECT timestamp_in( datetime_out( $1 ) ) WHERE $1 IS NOT NULL'
LANGUAGE 'sql';
Now, get your max with:
SELECT dt_to_ts( max( timestamp_field::datetime ) )
FROM the_table;
Herouth
--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma
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: herouth@oumail.openu.ac.il, echiner@tissat.es
Subject: Re: Max function on Timestamp
In-Reply-To: <l03130300b3f9532becaf@[147.233.159.109]>
References: <37CE3592.2558E205@tissat.es> <l03130300b3f9532becaf@[147.233.159.109]>
* 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