Function to offset current timestamp - Mailing list pgsql-admin

From Dan Harris
Subject Function to offset current timestamp
Date
Msg-id 46605886.1070404@drivefaster.net
Whole thread Raw
Responses Re: Function to offset current timestamp  (Dan Harris <fbsd@drivefaster.net>)
Re: Function to offset current timestamp  (Steve Crawford <scrawford@pinpointresearch.com>)
List pgsql-admin
I'm trying to write a function that can do a select on an integer value from a
table and subtract that value from current_timestamp.

Let's say I have a table called users and a field called tz_offset..

I want my function to do something like :

select current_timestamp - '( select tz_offset from users where userid = ? )
hours'::interval

Obviously this syntax is incorrect, but I'm not quite sure how to do the
subquery and make the integer result of it part of the quoted interval expression.

Any tips?

Thx

pgsql-admin by date:

Previous
From: "Hyatt, Gordon"
Date:
Subject: Failed install of PostgreSQL v8.2.4 - initdb fails with Access is denied
Next
From: Dan Harris
Date:
Subject: Re: Function to offset current timestamp