Re: age() function usage

From: "Marcin Krawczyk" <jankes(dot)mk(at)gmail(dot)com>
To: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: age() function usage
Date: 2008-01-25 19:53:12
Message-ID: 95f6bf9b0801251153s303f650ave9d4ff289ccee82@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Heh, that was easy, I must have been working for too long... :) Thanks

2008/1/25, Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>:
>
> On Jan 25, 2008 1:06 PM, Marcin Krawczyk <jankes(dot)mk(at)gmail(dot)com> wrote:
> > Hi all. I am trying to determine the way to pass a variable/field value
> to
> > an age() function, query looks something like:
> >
> > SELECT age(timestamp data_zakonczenia_fakt) FROM kip_pracownicy_umowy
> WHERE
> > id_pracownika = 8
> >
> > data_zakonczenia_fakt being char column equal to say '1993-11-30'.
> > Such approach won't work, can anyone tell me the way to do it?
> >
> > SELECT age(timestamp '1993-11-30') works great.
> > Same story with age(timestamp '2008-01-01', timestamp '1993-11-30').
>
> You need an explicit cast:
>
> SELECT age(data_zakonczenia_fakt::timestamp) FROM kip_pracownicy_umowy
> WHERE id_pracownika = 8
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Andrej Ricnik-Bay 2008-01-25 23:05:47 Re: Extract interdependent info from one table
Previous Message Scott Marlowe 2008-01-25 19:41:15 Re: age() function usage