Re: date time function

From: Michael Glaesemann <grzm(at)seespotcode(dot)net>
To: rod(at)iol(dot)ie
Cc: Jasbinder Singh Bali <jsbali(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: date time function
Date: 2007-06-28 21:28:51
Message-ID: C14E553E-F904-41EE-A226-22CED48C6FD0@seespotcode.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Jun 28, 2007, at 15:13 , Raymond O'Donnell wrote:

> Cast your result to type INTERVAL - something like this:
>
> postgres=# select (current_timestamp - timestamp
> '2007-05-01')::interval;
>
> interval
> ----------------------
> 58 days 21:10:36.748
> (1 row)

The cast to interval is superfluous: timestamp - timestamp already
gives you an interval result. Also, Postgres will interpret
'2007-05-01' as a date in this context:

# select current_timestamp - '2007-05-01';
?column?
-------------------------
58 days 16:25:53.776695
(1 row)

Michael Glaesemann
grzm seespotcode net

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2007-06-29 00:50:36 Re: AutoVacuum Behaviour Question
Previous Message Sergei Shelukhin 2007-06-28 20:22:54 what's wrong with this conf file?