From: Peter Faulks <faulksp@iinet.net.au>
To: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: date arithmetic with columns
Date: Thu, 01 Mar 2012 06:50:39 +1100
Message-ID: <4F4E818F.9030402@iinet.net.au> (raw)
I have two columns in two distinct tables, one is the starting time of
an event, timestamp without time zone. Data is the utc datetime (for
sorting across time zones), the other is the number of minutes to add.
I am migrating from Firebird. One of the queries uses the dateadd
function to build a local starting time thus:
SELECT CAST(DATEADD(tz.diffmins MINUTE TO r.utc) AS TIME) AS ts
FROM races r JOIN tracks t ON t.trk = r.trk
JOIN timezones tz on tz.state = t.state....
The equivalent postgres would be along the lines of
SELECT r.utc + INTERVAL '480 minutes'
How can I substitute the hard-coded 480 for the tz.diffmins?
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-sql@postgresql.org
Cc: faulksp@iinet.net.au
Subject: Re: date arithmetic with columns
In-Reply-To: <4F4E818F.9030402@iinet.net.au>
* 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