pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Erik Wasser <erik.wasser@iquer.net>
To: pgsql-sql@postgresql.org
Subject: Howto turn an integer into an interval?
Date: Tue, 5 Oct 2004 14:07:41 +0200
Message-ID: <200410051407.42037.erik.wasser@iquer.net> (raw)

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



view thread (5+ messages)  latest in thread

Message-ID: <200410051407.42037.erik.wasser@iquer.net>
Permalink:  ../200410051407.42037.erik.wasser@iquer.net/
Also on:    postgresql.org/message-id/200410051407.42037.erik.wasser@iquer.net

 · 

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: erik.wasser@iquer.net
  Subject: Re: Howto turn an integer into an interval?
  In-Reply-To: <200410051407.42037.erik.wasser@iquer.net>

* 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