X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 43472329E32 for ; Tue, 5 Oct 2004 13:07:55 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 75356-10 for ; Tue, 5 Oct 2004 12:07:45 +0000 (GMT) Received: from sv0.iquer.net (sv0.iquer.net [195.234.230.122]) by svr1.postgresql.org (Postfix) with SMTP id 43BAC329E12 for ; Tue, 5 Oct 2004 13:07:45 +0100 (BST) Received: (qmail 22646 invoked by uid 108); 5 Oct 2004 12:07:43 -0000 Received: from unknown (HELO ws1.int.iquer.net) (10.0.16.220) by sv0.iquer.net with SMTP; 5 Oct 2004 12:07:43 -0000 From: Erik Wasser Date: Tue, 5 Oct 2004 14:07:41 +0200 User-Agent: KMail/1.7 MIME-Version: 1.0 Content-Disposition: inline To: pgsql-sql@postgresql.org Subject: Howto turn an integer into an interval? Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <200410051407.42037.erik.wasser@iquer.net> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/25 X-Sequence-Number: 19128 Hi List, I got a table named foobar with two fields last_sms is a 'timestamp without timezone' resend_interval is a 'integer' I choose 'integer' for resend_interval rather than a 'interval' because the frontend can easier handle the number of seconds. But now I'm stuck with the query to get all rows that we're older than 'resend_interval' in seconds. My first try was: SELECT * FROM sms_groups WHERE (current_timestamp - last_sms) > '3600 seconds'::interval This is working great and returns all rows that are older than a hour. But how I do this with the colum 'resend_interval' in the query? SELECT * FROM sms_groups WHERE (current_timestamp - last_sms) > resend_interval::interval gives me only a "cannot cast type integer to interval". So how can I turn an integer to an interval? Or is there an other solution? Suggestions? P.S: I'm using psql '7.4.5' of gentoo. -- So long... Fuzz