pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
date arithmetic
2+ messages / 2 participants
[nested] [flat]

* date arithmetic
@ 2006-08-08 21:27 chrisj <chrisj.wood@sympatico.ca>
  2006-08-10 19:21 ` Re: date arithmetic Osvaldo Rosario Kussama <osvaldo_kussama@yahoo.com.br>
  0 siblings, 1 reply; 2+ messages in thread

From: chrisj @ 2006-08-08 21:27 UTC (permalink / raw)
  To: pgsql-sql


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"
-- 
View this message in context: http://www.nabble.com/date-arithmetic-tf2075353.html#a5715425
Sent from the PostgreSQL - sql forum at Nabble.com.




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: date arithmetic
  2006-08-08 21:27 date arithmetic chrisj <chrisj.wood@sympatico.ca>
@ 2006-08-10 19:21 ` Osvaldo Rosario Kussama <osvaldo_kussama@yahoo.com.br>
  0 siblings, 0 replies; 2+ messages in thread

From: Osvaldo Rosario Kussama @ 2006-08-10 19:21 UTC (permalink / raw)
  To: chrisj <chrisj.wood@sympatico.ca>; pgsql-sql

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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2006-08-10 19:21 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-08-08 21:27 date arithmetic chrisj <chrisj.wood@sympatico.ca>
2006-08-10 19:21 ` Osvaldo Rosario Kussama <osvaldo_kussama@yahoo.com.br>

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