pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: pgsql-sql@postgreSQL.org
Subject: Timespan conversion
Date: Sun, 27 Sep 1998 14:53:53 +0200
Message-ID: <l03110703b233e2cdd004@[147.233.159.109]> (raw)

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





Message-ID: <l03110703b233e2cdd004@[147.233.159.109]>
Permalink:  ../l03110703b233e2cdd004@%5B147.233.159.109%5D/
Also on:    postgresql.org/message-id/l03110703b233e2cdd004@[147.233.159.109]

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: herouth@oumail.openu.ac.il
  Subject: Re: Timespan conversion
  In-Reply-To: <l03110703b233e2cdd004@[147.233.159.109]>
  References: <l03110703b233e2cdd004@[147.233.159.109]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox