Received: from shaked.cc.openu.ac.il (shaked.cc.openu.ac.il [147.233.145.65]) by hub.org (8.8.8/8.8.8) with ESMTP id IAA23164 for ; Sun, 27 Sep 1998 08:53:18 -0400 (EDT) (envelope-from herouth@oumail.openu.ac.il) Received: from [147.233.159.109] (herouth@mac-herouth.pc.openu.ac.il [147.233.159.109]) by shaked.cc.openu.ac.il (8.8.5/8.8.5) with ESMTP id OAA20419 for ; Sun, 27 Sep 1998 14:53:06 +0200 (IST) X-Sender: herouth@shaked.cc.openu.ac.il Message-Id: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Date: Sun, 27 Sep 1998 14:53:53 +0200 To: pgsql-sql@postgreSQL.org From: Herouth Maoz Subject: Timespan conversion I currently run Postgres 6.2.1. I wanted to use it to compute my basketball statistics (the classical relational database application) - enter the rows from the box scores, and get all sorts of statistics. My question relates to the 'minutes played' column. The natural implementation is timespan, because I get times in mm:ss format. Timespans sum up nicely. The problem begins in calculations such as "average minutes per game", "minutes between rebounds", etc. There is no problem in converting timespans to float. I just take the date_part( 'epoch', timespan_field ), and divide it by, say, 60. My problem is, after I divide this by the number of games, how do I convert back to timespan? Also, is there a way to receive '20:30' or maybe '00:20:30' and not '20 minutes 30 seconds' as a display from timespan? I don't want to build an application for all this, because, frankly, it's just a hobby. Most of the work can be done rather well in simplest SQL. Herouth -- Herouth Maoz, Internet developer. Open University of Israel - Telem project http://telem.openu.ac.il/~herutma