From: | "Stijn Vanroye" <s(dot)vanroye(at)Farcourier(dot)com> |
---|---|
To: | "togy(at)icube" <martin(dot)tongel(at)icubestudio(dot)com> |
Cc: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Your question in postgresql.org forum (Diff. between two times as a numeric value in a stored proc) |
Date: | 2004-06-16 07:27:24 |
Message-ID: | 736CEAA26E7E3F48943458F760E7A32603B622@fs1300.farcourier.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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(at)icube [mailto:martin(dot)tongel(at)icubestudio(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Christoph Haller | 2004-06-16 11:52:57 | How to delete the not DISTINCT ON entries |
Previous Message | Michalis Kabrianis | 2004-06-16 06:47:17 | Re: Last insert id |