From: | "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | question with times and intervals |
Date: | 2006-01-26 11:58:16 |
Message-ID: | 20060126115816.GA9924@webserv.wug-glas.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hi,
I have a table like this:
test=# select * from status_log ;
id | status | t_start | t_end
----+--------+------------------------+------------------------
1 | 1 | 2006-01-20 23:00:00+01 | 2006-01-21 06:00:00+01
1 | 1 | 2006-01-21 06:00:00+01 | 2006-01-21 22:00:00+01
1 | 2 | 2006-01-21 22:00:00+01 | 2006-01-22 05:00:00+01
1 | 1 | 2006-01-22 05:00:00+01 | 2006-01-22 15:00:00+01
1 | 2 | 2006-01-22 15:00:00+01 | 2006-01-23 02:00:00+01
(5 rows)
Now i need for a particular intervall (one day or two days, entires
days) the accumulated time for id=X and status=Y.
Exampel:
id=1, status=1, date=2006-01-21:
from 00:00:00 - 06:00:00 and
06:00:00 - 22:00:00
===> 6 hours + 16 hours = 22 hours
id=1, status=2, date=2006-01-21:
from 22:00:00 - 23:59:59
===> 2 hours
I need also this for a week or month. How can i calculate this?
Thanks very much for help.
--
Andreas Kretschmer (Kontakt: siehe Header)
Heynitz: 035242/47215, D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
=== Schollglas Unternehmensgruppe ===
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Huxton | 2006-01-26 12:09:11 | Re: question with times and intervals |
Previous Message | Andrew Sullivan | 2006-01-26 11:39:02 | Re: Changing the transaction isolation level within the stored |