pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dan Harris <fbsd@drivefaster.net>
To: pgsql-admin@postgresql.org
Subject: Function to offset current timestamp
Date: Fri, 01 Jun 2007 11:33:58 -0600
Message-ID: <46605886.1070404@drivefaster.net> (raw)

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



view thread (4+ messages)  latest in thread

Message-ID: <46605886.1070404@drivefaster.net>
Permalink:  ../46605886.1070404@drivefaster.net/
Also on:    postgresql.org/message-id/46605886.1070404@drivefaster.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: fbsd@drivefaster.net
  Subject: Re: Function to offset current timestamp
  In-Reply-To: <46605886.1070404@drivefaster.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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