pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Contertine timespan to hours
2+ messages / 2 participants
[nested] [flat]

* Contertine timespan to hours
@ 1998-08-28 18:17 Shawn T. Walker <swalker@iac.net>
  1998-08-30 08:40 ` Re: [SQL] Contertine timespan to hours Herouth Maoz <herouth@oumail.openu.ac.il>
  0 siblings, 1 reply; 2+ messages in thread

From: Shawn T. Walker @ 1998-08-28 18:17 UTC (permalink / raw)
  To: pgsql-sql

All,

	I have a table of a timespan.  I get it in days,hours,and
minutes.  I need to convert the entire thing to hours.

select sum(totaltime) from usage1998;

returns: 
sum
-------------------------------------
@ 12468 days 23 hours 40 mins 45 secs
(1 row)                               

I need thevalue in just hours... Can anyone give me a hand...

Thanks in advance!:)

-- 
                                                         
           Shawn T. Walker  swalker@iac.net              
              Internet Access Cincinnati                 
                  http://www.iac.net

"Running enterprise applications on NT? Let the torture begin."
          - A Sun Microsystems Inc. banner ad



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [SQL] Contertine timespan to hours
  1998-08-28 18:17 Contertine timespan to hours Shawn T. Walker <swalker@iac.net>
@ 1998-08-30 08:40 ` Herouth Maoz <herouth@oumail.openu.ac.il>
  0 siblings, 0 replies; 2+ messages in thread

From: Herouth Maoz @ 1998-08-30 08:40 UTC (permalink / raw)
  To: Shawn T. Walker <swalker@iac.net>; +Cc: pgsql-sql

At 21:17 +0300 on 28/8/98, Shawn T. Walker wrote:


>
> 	I have a table of a timespan.  I get it in days,hours,and
> minutes.  I need to convert the entire thing to hours.
>
> select sum(totaltime) from usage1998;
>
> returns:
> sum
> -------------------------------------
> @ 12468 days 23 hours 40 mins 45 secs
> (1 row)
>
> I need thevalue in just hours... Can anyone give me a hand...

testing=> \d test3

Table    = test3
+-----------------------------+-----------------------------+-------+
|           Field             |              Type           | Length|
+-----------------------------+-----------------------------+-------+
| ts                          | timespan                    |    12 |
+-----------------------------+-----------------------------+-------+
testing=> SELECT * FROM test3;
ts
------------------------
@ 6 days 4 hours 32 mins
@ 200 days 3 hours
@ 17 hours
@ 3 hours 8 mins ago
(4 rows)

testing=> SELECT % ( date_part( 'epoch', ts ) / 3600 ) FROM test3;
?column?
--------
     148
    4803
      17
      -3
(4 rows)

The date_part with 'epoch' converts the timespan to seconds. You convert it
to hours by dividing by 3600, and you use % to round it.

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~1998-08-30 08:40 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1998-08-28 18:17 Contertine timespan to hours Shawn T. Walker <swalker@iac.net>
1998-08-30 08:40 ` Herouth Maoz <herouth@oumail.openu.ac.il>

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