Re: How to return an INT4 subtracting dates?

From: Raymond O'Donnell <rod(at)iol(dot)ie>
To: Andre Lopes <lopes80andre(at)gmail(dot)com>
Cc: postgresql Forums <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to return an INT4 subtracting dates?
Date: 2010-06-09 11:10:08
Message-ID: 4C0F7690.2000704@iol.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 09/06/2010 11:57, Andre Lopes wrote:
> Hi,
>
> I need to return an int4 subtracting two dates, but returns me an interval.
>
> select
> end_date - now() as interger_number
> from hist_anuncios
>
> How to return an integer out of this?

Hmmm, according to the docs, subtracting dates returns an integer:

http://www.postgresql.org/docs/8.4/static/functions-datetime.html

Try "current_date", which gives you a date, instead of "now", which
gives you a timestamp.

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod(at)iol(dot)ie

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Massa, Harald Armin 2010-06-09 11:38:40 Windows: Compiling and linking dynamically-loaded functions
Previous Message Pavel Stehule 2010-06-09 11:02:46 Re: How to return an INT4 subtracting dates?