By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,775 Members | 1,740 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,775 IT Pros & Developers. It's quick & easy.

Problem with showing time diff?

P: n/a
I have the following select:

select to_char((Log_Fortrykk.SistePlate::time -
OrdreNew.SistePlate::time)::interval,'HH24:MI') as diff from Log_Fortrykk

I need the output to be HH:MM, e.g. 00:09... But my prb is when this diff is less than 0,
it shows as 00:-9 and not -00:09

How can I fix this?
Regards,

BTJ

--
-----------------------------------------------------------------------------------------------
Bjørn T Johansen

bt*@havleik.no
-----------------------------------------------------------------------------------------------
Someone wrote:
"I understand that if you play a Windows CD backwards you hear strange Satanic messages"
To which someone replied:
"It's even worse than that; play it forwards and it installs Windows"
-----------------------------------------------------------------------------------------------

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Thu, Nov 11, 2004 at 11:55:33AM +0100, Bjørn T Johansen wrote:

select to_char((Log_Fortrykk.SistePlate::time -
OrdreNew.SistePlate::time)::interval,'HH24:MI') as diff from Log_Fortrykk

I need the output to be HH:MM, e.g. 00:09... But my prb is when this diff
is less than 0, it shows as 00:-9 and not -00:09


The documentation deprecates to_char(interval, text) and the Release
Notes for 8.0 say that 8.1 will remove it.

You might be able to use substring():

SELECT substring('-00:09:10'::interval from '(.*):[0-9][0-9]$');
substring
-----------
-00:09
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.