pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Scott Marlowe <scott.marlowe@gmail.com>
To: Marcin Krawczyk <jankes.mk@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: age() function usage
Date: Fri, 25 Jan 2008 13:41:15 -0600
Message-ID: <dcc563d10801251141u3422dc42tf3c57b06a77f19ff@mail.gmail.com> (raw)
In-Reply-To: <95f6bf9b0801251106h6577fa94j508574db50030b53@mail.gmail.com>
References: <95f6bf9b0801251106h6577fa94j508574db50030b53@mail.gmail.com>

On Jan 25, 2008 1:06 PM, Marcin Krawczyk <jankes.mk@gmail.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



view thread (3+ messages)  latest in thread

Message-ID: <dcc563d10801251141u3422dc42tf3c57b06a77f19ff@mail.gmail.com>
Permalink:  ../dcc563d10801251141u3422dc42tf3c57b06a77f19ff@mail.gmail.com/
Also on:    postgresql.org/message-id/dcc563d10801251141u3422dc42tf3c57b06a77f19ff@mail.gmail.com

 · 

reply

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: scott.marlowe@gmail.com, jankes.mk@gmail.com
  Subject: Re: age() function usage
  In-Reply-To: <dcc563d10801251141u3422dc42tf3c57b06a77f19ff@mail.gmail.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