Re: Interval Formatting -> Convert to timestamp
| От | Tomasz Ostrowski |
|---|---|
| Тема | Re: Interval Formatting -> Convert to timestamp |
| Дата | |
| Msg-id | 48AD3B12.9030401@batory.org.pl обсуждение исходный текст |
| Ответ на | Interval Formatting -> Convert to timestamp ("Ow Mun Heng" <ow.mun.heng@wdc.com>) |
| Ответы |
Re: Interval Formatting -> Convert to timestamp
|
| Список | pgsql-general |
On 2008-08-21 11:09, Ow Mun Heng wrote:
> I want to find out if there's a method to change this
> select to_char('1 day 09:18:42.37996'::interval,'HH24:MI:SS')
> to something like
> 24+9(hours) = 33:18:42 instead of returning It as 09:19:42
That's because 1 day doesn't always have 24 hours, because there are
daylight saving times. 1 month can also have various number of days or
hours.
If you want 1 day to be always 24 hours then:
select date_part('day', t)*'24h'::interval + t-date_trunc('day',t)
from (select '1 day 09:18:42.37996'::interval as t) as s;
It will not work for intervals with months. I'm not sure for negative ones.
Regards
Tometzky
--
...although Eating Honey was a very good thing to do, there was a
moment just before you began to eat it which was better than when you
were...
Winnie the Pooh
В списке pgsql-general по дате отправления: