Re: Interval Question

Поиск
Список
Период
Сортировка
От Terry Lee Tucker
Тема Re: Interval Question
Дата
Msg-id 200501111054.25492.terry@esc1.com
обсуждение исходный текст
Ответ на Re: Interval Question  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Check this out:
rnd=# show DateStyle;
 DateStyle
-----------
 SQL, MDY
(1 row)

rnd=# select interval '@ 3 days 4 hours 17 mins'::interval - '@ 3 days 6 hours
17 mins'::interval;
 ?column?
-----------
 @ 2 hours
(1 row)

And...
rnd=# set DateStyle to postgres;
SET
rnd=# select interval '@ 3 days 4 hours 17 mins'::interval - '@ 3 days 6 hours
17 mins'::interval;
   ?column?
---------------
 @ 2 hours ago
(1 row)

Here is my Version:
PostgreSQL 7.4.6 on i686-redhat-linux-gnu, compiled by GCC gcc (GCC) 3.2.3
20030502 (Red Hat Linux 3.2.3-42)

On Tuesday 11 January 2005 10:19 am, Tom Lane saith:
> Terry Lee Tucker <terry@esc1.com> writes:
> > I thought that subtracting the larger interval from
> > the small would return this but it is always the absolute value.
>
> Eh?
>
> regression=# set DateStyle TO ISO;
> SET
> regression=# select '@ 3 days 4 hours 17 mins'::interval -
> regression-# '@ 3 days 6 hours 17 mins'::interval;
>  ?column?
> -----------
>  -02:00:00
> (1 row)
>
> regression=# set DateStyle TO postgres;
> SET
> regression=# select '@ 3 days 4 hours 17 mins'::interval -
> regression-# '@ 3 days 6 hours 17 mins'::interval;
>    ?column?
> ---------------
>  @ 2 hours ago
> (1 row)
>
> and as for detecting whether it's negative,
>
> regression=# select ('@ 3 days 4 hours 17 mins'::interval -
> regression(# '@ 3 days 6 hours 17 mins'::interval) < '0'::interval;
>  ?column?
> ----------
>  t
> (1 row)
>
>             regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if your
>       joining column's datatypes do not match

--
Quote: 59
"The concessions of the weak are the concessions of fear."

 --Mark Twain

 Work: 1-336-372-6812
 Cell: 1-336-363-4719
email: terry@esc1.com

В списке pgsql-general по дате отправления:

Предыдущее
От: Daniel Schuchardt
Дата:
Сообщение: Re: PostgreSQL 8 on windows very slow
Следующее
От: "Joshua D. Drake"
Дата:
Сообщение: Re: PL/Perl