From: Stijn Vanroye <s.vanroye@Farcourier.com>
To: togy@icube <martin.tongel@icubestudio.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Your question in postgresql.org forum (Diff. between two times as a numeric value in a stored proc)
Date: Wed, 16 Jun 2004 09:27:24 +0200
Message-ID: <736CEAA26E7E3F48943458F760E7A32603B622@fs1300.farcourier.com> (raw)
Hello Martin,
There's not much hint to it, here's a solution instead :)
You can make use of several built-in functions to handle strings, date/time values etc. Take a look at chapter 9: Functions and Operators of your PostgreSQL documentation all available functions are explained there.
To solve my problem I used the extract EXTRACT (field FROM source) function, as described in paragraph 9.8.1.
You can use it to extract a certain field form your timestamp vield, for example:
extract (hour from timestamp '2004-16-04 09:21:52') returns 9
SELECT EXTRACT(EPOCH FROM INTERVAL '5 days 3 hours');
Result: 442800
EPOCH will return the number of seconds. You can multiply those by n*60, depending if you want minutes or hours.
At first I used a different calculation, but this one should be less work :).
I hope you're problem is solved that way.
I took the liberty of CC-ing the postgresql mailinglist so other's having a similar problem can read about this solution too. It's all about the (open-source)-community isn't it :)
Kind regards,
Stijn Vanroye
-----Original Message-----
From: togy@icube [mailto:martin.tongel@icubestudio.com]
Sent: dinsdag 15 juni 2004 19:08
To: Stijn Vanroye
Subject: Your question in postgresql.org forum
Hello Stijn,
I read your question in postgresql.org forum published under sunject "Difference between two times as a numeric value in a stored procedure"
I am currently solving the same problem... Did you solve it somehow? Can you give a hint please?
Best Regards,
Martin Tongel
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: s.vanroye@Farcourier.com, martin.tongel@icubestudio.com
Subject: Re: Your question in postgresql.org forum (Diff. between two times as a numeric value in a stored proc)
In-Reply-To: <736CEAA26E7E3F48943458F760E7A32603B622@fs1300.farcourier.com>
References: <736CEAA26E7E3F48943458F760E7A32603B622@fs1300.farcourier.com>
* 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