Re: Does anyone use TO_CHAR(INTERVAL)?
От | Tomasz Myrta |
---|---|
Тема | Re: Does anyone use TO_CHAR(INTERVAL)? |
Дата | |
Msg-id | 3E81620E.20604@klaster.net обсуждение исходный текст |
Ответ на | Re: Does anyone use TO_CHAR(INTERVAL)? (Bruno Wolff III <bruno@wolff.to>) |
Ответы |
Re: Does anyone use TO_CHAR(INTERVAL)?
|
Список | pgsql-sql |
Uz.ytkownik Bruno Wolff III napisa?: > On Tue, Mar 25, 2003 at 20:24:55 +0100, > Tomasz Myrta <jasiek@klaster.net> wrote: > >>Uz.ytkownik Josh Berkus napisa?: >> >>It looks it could be useful to display how much time is left for >>scheduling cases, but as I wrote few threads ago - displaying intervals >>longer than one month is useless without specific date. > > > That isn't true. Intervals have two parts. One is time difference in > fixed time and the other is a difference in months. You could display > both parts when they are both nonzero. > > I haven't found the documenation too specific on which part gets added > first (and this does make a difference in some cases). It looks like you are right: SELECT cast('300 days' as interval)+cast('1 month' as interval);; ?column? ---------------- 1 mon 300 days SELECT to_char(cast('300 days' as interval)+cast('1 month' as interval),'DDD');; to_char --------- 300 (1 row) SELECT to_char('2002-12-31'::timestamp -'2002-01-01'::timestamp,'YYYY-MM-DD');; to_char ------------- 0000-00-36 (1 row) Thanks for noticing this, these results are really strange for me. I should remember NOT to use months when working with intervals. It looks like intervals contain 2 totally independent values inside. I have one more question to this thread - Does anyone use intervals month value? Tomasz
В списке pgsql-sql по дате отправления: