pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Osvaldo Rosario Kussama <osvaldo_kussama@yahoo.com.br>
To: chrisj <chrisj.wood@sympatico.ca>
To: pgsql-sql@postgresql.org
Subject: Re: date arithmetic
Date: Thu, 10 Aug 2006 16:21:07 -0300
Message-ID: <44DB8723.6020401@yahoo.com.br> (raw)
In-Reply-To: <5715425.post@talk.nabble.com>
References: <5715425.post@talk.nabble.com>

chrisj escreveu:
> Hi ALL,
> 
> I want to do date arithmetic in SQL with a column that is integer.
> 
> example
> 
> create table bob (
>   col1   timestamp
> , col2   int4
> ;
> 
> where col2 represents a number of minutes.
> 
> 
> I want to do something like
> 
> select col1 + interval col2 minutes
>   from bob
> 
> This is doable with most other RDBMS (DB2, Oracle MS SQL) what am I
> missing??
> 
> I know one option is to create col2 as interval, but does not work for me.
> How can I cast int4 to "interval minutes"


SELECT col1 + col2*interval '1 miunute' FROM bob;

[]s
Osvaldo

		
_______________________________________________________ 
Yahoo! Acesso Grátis - Internet rápida e grátis. Instale 
o discador agora! 
http://br.acesso.yahoo.com



view thread (2+ messages)

Message-ID: <44DB8723.6020401@yahoo.com.br>
Permalink:  ../44DB8723.6020401@yahoo.com.br/
Also on:    postgresql.org/message-id/44DB8723.6020401@yahoo.com.br

 · 

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: osvaldo_kussama@yahoo.com.br, chrisj.wood@sympatico.ca
  Subject: Re: date arithmetic
  In-Reply-To: <44DB8723.6020401@yahoo.com.br>

* 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