Thread: how to convert a time interval to seconds?
Hi, I searched how to convert a time interval to seconds but failed to find an example. I want to convert the following wait_time column into seconds. How can I do that? The datatype for the wait_time is time without timezone. job_number | task_number | submission_time | wait_time ------------+-------------+---------------------+----------- 56 | 0 | 2006-04-13 08:47:53 | 00:01:28 55 | 0 | 2006-04-13 08:47:51 | 00:01:21 58 | 0 | 2006-04-13 08:47:54 | 00:01:28 60 | 0 | 2006-04-13 08:47:55 | 00:01:27 Thanks, - Chansup
On Tue, Sep 12, 2006 at 10:39:25AM -0400, Chansup Byun wrote: > I searched how to convert a time interval to seconds but failed to find > an example. Searching the list archives for "interval to seconds" returns many examples. See also "Date/Time Functions and Operators" in the documentation. http://archives.postgresql.org/ http://www.postgresql.org/docs/8.1/interactive/functions-datetime.html EXTRACT(EPOCH FROM interval_value) > I want to convert the following wait_time column into seconds. How can I > do that? The datatype for the wait_time is time without timezone. > > job_number | task_number | submission_time | wait_time > ------------+-------------+---------------------+----------- > 56 | 0 | 2006-04-13 08:47:53 | 00:01:28 Does wait_time represent a duration? If so then why is it a time without timezone instead of an interval? -- Michael Fuhr
am Tue, dem 12.09.2006, um 10:39:25 -0400 mailte Chansup Byun folgendes: > Hi, > > I searched how to convert a time interval to seconds but failed to find > an example. select extract('epoch' from timestamp); A little example: test=*> select '5 days 5 hours'::interval; interval ----------------- 5 days 05:00:00 (1 row) test=*> select extract ('epoch' from '5 days 5 hours'::interval); date_part ----------- 450000 (1 row) http://www.postgresql.org/docs/8.1/interactive/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT HTH, Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47215, D1: 0160/7141639 (mehr: -> Header) GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net