Re: convert time format retuned by a select query - Mailing list pgsql-novice

From Jayadevan M
Subject Re: convert time format retuned by a select query
Date
Msg-id OF124301AD.4719D8B7-ON65257961.00143972-65257961.00145567@ibsplc.com
Whole thread Raw
In response to convert time format retuned by a select query  (Johan Martinez <jmartiee@gmail.com>)
List pgsql-novice
Hello,
>
> I would like to subtract two columns - create_time and update_time
> of 'timestamp without time zone' type and then order results based
> on subtraction-result (time interval). I checked http://
>
www.postgresql.org/docs/current/static/functions-datetime.html ,
> however these examples didn't work with actual column values.
> e.g.something like:  

> 'select epoch (update_time) - epoch (create_time) AS Column1 from
> users order by Column1; '

Will this do?
test=# select update_time, create_time, update_time-create_time as diff from myt
 order by update_time-create_time  desc;
       update_time       |       create_time       |      diff
-------------------------+-------------------------+-----------------
 2011-12-12 00:09:28.852 | 2011-12-09 09:09:28.852 | 2 days 15:00:00
 2011-12-11 19:09:22.619 | 2011-12-09 09:09:22.619 | 2 days 10:00:00
 2011-12-11 09:09:15.744 | 2011-12-09 09:09:15.744 | 2 days
 2011-12-10 09:09:10.104 | 2011-12-09 09:09:10.104 | 1 day
(4 rows)

Regards,
Jayadevan





DISCLAIMER:


"The information in this e-mail and any attachment is intended only for the person to whom it is addressed and may contain confidential and/or privileged material. If you have received this e-mail in error, kindly contact the sender and destroy all copies of the original communication. IBS makes no warranty, express or implied, nor guarantees the accuracy, adequacy or completeness of the information contained in this email or any attachment and is not liable for any errors, defects, omissions, viruses or for resultant loss or damage, if any, direct or indirect."





pgsql-novice by date:

Previous
From: Michael Rowan
Date:
Subject: pgAdmin3 grant wizard question
Next
From: "Jean-Yves F. Barbier"
Date:
Subject: Re: pgAdmin3 grant wizard question