Skip site navigation (1) Skip section navigation (2)

Re: Your question in postgresql.org forum (Diff. between two times as a numeric value in a stored proc)

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 (view raw or flat)
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

pgsql-sql by date

Next:From: Christoph HallerDate: 2004-06-16 11:52:57
Subject: How to delete the not DISTINCT ON entries
Previous:From: Michalis KabrianisDate: 2004-06-16 06:47:17
Subject: Re: Last insert id

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group