Re: problems with date and interval queries.

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

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.

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, ...)

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Jean-Luc Lachance 2003-02-10 18:32:54 Re: order by date desc but NULLs last
Previous Message Stephan Szabo 2003-02-10 18:14:15 Re: problems with date and interval queries.