Skip site navigation (1) Skip section navigation (2)

extract and interval

From: Luiz Eduardo Cantanhede Neri <lecneri(at)gmail(dot)com>
To: postgresql novice <pgsql-novice(at)postgresql(dot)org>
Subject: extract and interval
Date: 2009-05-25 13:15:42
Message-ID: 252e1f290905250615h7569127bqc4f46fcb3be29906@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-novice
Is there an good way to extract the interval unit that were used?

E.g. I used interval '2h' and another case I used '3d', theses are
respectively  2 hours and 3 days, but the format that came on select is
'02:00:00' for hour and '3 days' for days

What I'm looking for is something like 2h and 3d just as inserted.
The only solution so far I could came up with is call to_char function using
the unit of time and get the highest position for each couple of digits.
Ex: to_char(interval, 'DDHH24')
let's suppose the result is 0003 then I know it's 3 hours if I get 0100 I
know it's 1 day.

Open to suggestions :)

pgsql-novice by date

Next:From: Oliveiros CristinaDate: 2009-05-25 13:32:14
Subject: Obtaining a limited number of records from a long query
Previous:From: Luiz Eduardo Cantanhede NeriDate: 2009-05-25 10:44:36
Subject: Tool for modeling

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group