Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 375862E3397 for ; Fri, 25 Jan 2008 15:41:20 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 60536-06 for ; Fri, 25 Jan 2008 15:41:14 -0400 (AST) Received: from wa-out-1112.google.com (wa-out-1112.google.com [209.85.146.179]) by postgresql.org (Postfix) with ESMTP id 599722E3392 for ; Fri, 25 Jan 2008 15:41:16 -0400 (AST) Received: by wa-out-1112.google.com with SMTP id m38so1336247waf.5 for ; Fri, 25 Jan 2008 11:41:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=YEkPi7/22JuBz/bYjg779NCkXXlIWojxaSBqDLziM8U=; b=xVEFGsfujo4NougAjETJLOHOa8/CavXexmZMwqXvhcxiTp+IU6bRuhhy5ryZ3TNYviIqh6xgnY6mvqF9r/QSGL/vl2oKj7/anyKsUKWJZVhoEg485rvFDHNuo5I0eLlzSGaYlNM2BX2M9QyQvXi3YuYxIxl3WZlpP1nEIFcguNY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=jNVrqgoN6Mhmoh+z6bbdEI29LBoiLgb57p4pe6m+4AOT+euihQxiBp4M7mFJ9YPKN1WRrNSGSobGhMQ/AAsdIogbhm2wWr1ldsgYYcNJzMo+4sBmN47iBEtoe5EQ2O5mNDSzVzxNuhNN1qd19vZ/NF2h7gF29ivJnP4eHXV6yKg= Received: by 10.114.133.1 with SMTP id g1mr2737351wad.81.1201290075315; Fri, 25 Jan 2008 11:41:15 -0800 (PST) Received: by 10.114.133.5 with HTTP; Fri, 25 Jan 2008 11:41:15 -0800 (PST) Message-ID: Date: Fri, 25 Jan 2008 13:41:15 -0600 From: "Scott Marlowe" To: "Marcin Krawczyk" Subject: Re: age() function usage Cc: pgsql-sql@postgresql.org In-Reply-To: <95f6bf9b0801251106h6577fa94j508574db50030b53@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <95f6bf9b0801251106h6577fa94j508574db50030b53@mail.gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200801/203 X-Sequence-Number: 30056 On Jan 25, 2008 1:06 PM, Marcin Krawczyk 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