Re: problems with date and interval queries.

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <john(at)flowlabs(dot)com>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: problems with date and interval queries.
Date: 2003-02-10 19:03:43
Message-ID: 20030210110244.G234-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


On Mon, 10 Feb 2003, Tom Lane wrote:

> Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> writes:
> > interval <stuff> is the form for an interval literal. If the column is
> > already an interval, you probably don't need it at all. If you need to
> > cast it you should do a cast CAST (num_min AS INTERVAL)
>
> I don't believe there is a cast from any numeric type to interval.

Yeah, but I think he was making an interval string in the subselect,
something like '27 minutes'.

> I'd recommend the interval-times-float operator. It should work to
> write
>
> num_min * interval '1 min'
>
> This approach has the advantage that it trivially adapts to whatever
> unit you happen to have the column stated in (seconds, minutes, days, ...)

That's better in any case though :)

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message greg 2003-02-10 21:04:24 Re: conversi ms-sql7 vs postgresql 7.3
Previous Message Ross J. Reedstrom 2003-02-10 18:52:44 Re: order by date desc but NULLs last