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

* timespan casting
@ 2000-06-22 23:46 Jeff MacDonald <jeff@pgsql.com>
  2000-06-23 01:55 ` Re: timespan casting Ed Loehr <eloehr@austin.rr.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Jeff MacDonald @ 2000-06-22 23:46 UTC (permalink / raw)
  To: pgsql-sql

hi,

thought this up while playing with time spans..

here is my table and data..

bignose=> \d foo
           Table "foo"
 Attribute |   Type    | Modifier 
-----------+-----------+----------
 start     | timestamp | 
 stop      | timestamp | 

bignose=> select start,stop, stop-start as start_stop from foo;
         start          |          stop          | start_stop 
------------------------+------------------------+------------
 2000-06-22 20:37:12-03 | 2000-06-22 20:37:12-03 | 00:000
 2000-06-22 20:40:40-03 | 2000-06-23 20:40:40-03 | 1 00:00
 2000-06-22 20:40:53-03 | 2000-09-30 20:40:53-03 | 100 00:00
 2000-06-22 20:41:08-03 | 2000-06-23 02:41:08-03 | 06:00
 2000-06-22 20:41:30-03 | 2010-11-22 19:41:30-04 | 3805 00:00
(5 rows)

now my question.. first of all is the first start_stop result a little
off ? (talking about the 3 0's..)

second is there a way i can do a select so it says something more human
usable ie : 100 days 22 hours 32 minutes..

jeff






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

* Re: timespan casting
  2000-06-22 23:46 timespan casting Jeff MacDonald <jeff@pgsql.com>
@ 2000-06-23 01:55 ` Ed Loehr <eloehr@austin.rr.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Ed Loehr @ 2000-06-23 01:55 UTC (permalink / raw)
  To: Jeff MacDonald <jeff@pgsql.com>; +Cc: pgsql-sql

Jeff MacDonald wrote:
> bignose=> select start,stop, stop-start as start_stop from foo;
>          start          |          stop          | start_stop
> ------------------------+------------------------+------------
>  2000-06-22 20:37:12-03 | 2000-06-22 20:37:12-03 | 00:000
> 
> now my question.. first of all is the first start_stop result a little
> off ? (talking about the 3 0's..)

What's off about it??  Your start and stop appear identical.

> second is there a way i can do a select so it says something more human
> usable ie : 100 days 22 hours 32 minutes..

Try to_char().  http://www.postgresql.org/docs/postgres/x2976.htm

Regards,
Ed Loehr



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


end of thread, other threads:[~2000-06-23 01:55 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-06-22 23:46 timespan casting Jeff MacDonald <jeff@pgsql.com>
2000-06-23 01:55 ` Ed Loehr <eloehr@austin.rr.com>

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