Re: porting time calcs to PG

From: Andrew Sullivan <ajs(at)crankycanuck(dot)ca>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: porting time calcs to PG
Date: 2006-12-08 11:42:17
Message-ID: 20061208114217.GC12351@phlogiston.dyndns.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Dec 07, 2006 at 04:44:35PM -0700, greg(at)bryantrecording(dot)com wrote:
> fields. The WHERE clause that I use in SQL Server is:
> getdate() + ((2100 + 5 + (9*Points)) / 86400) >= DueTime
>
> Where the numbers are actually parameters passed in to the function.
> Other than changine getdate() to now(), I'm not sure how to change the
> + interval to be effective. All the docs I see use something like
> interval '1 hour' - not sure how to put a calculated value in the
> quotes. Is this possible?

Sure. Something like

SELECT CURRENT_TIMESTAMP + (((2100 + 5 + (9*"Points")) /
86400) || 'seconds')::interval >= "DueTime"

oughta work.

--
Andrew Sullivan | ajs(at)crankycanuck(dot)ca
The plural of anecdote is not data.
--Roger Brinner

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ragnar 2006-12-08 11:52:41 Re: error with Subquery
Previous Message surabhi.ahuja 2006-12-08 11:29:13 delete in PG 8.1.5 is slow