Обсуждение: Interval Format

Поиск
Список
Период
Сортировка

Interval Format

От
Zagato
Дата:
Hi everyone... im looking for some help with the interval format between two diferents versions of postgres....<br />I
haveinstaled in my old server postgres 8.0.3 and in my new one postgres <a href="http://8.3.5.">8.3.5.</a>..<br />
Everythingin both looks works nice but i notice a little difference that is taking my crazy..<br />I have som SQL that
in8.0.3 do:<br /># SELECT '32 hours'::INTERVAL;<br />    interval<br />-----------------<br /> @ 1 day 8 hours<br /> (1
row)<br/><br />And in 8.3.5 do:<br />seg_veh2=# SELECT '@ 32 hours'::INTERVAL;<br />  interval<br />------------<br
/> @32 hours<br />(1 row)<br /><br clear="all" />Why i unable to get my old style of interval, i really need to see the
daypart.... im using datestyle german in both.... im try with "SET IntervalStyle TO..." but i get this error:<br />
ERROR: unrecognized configuration parameter "intervalstyle"<br />looking throw the forums i get that this new param its
justfor postgres 8.4...<br />So.. how can i recover my "days" part...<br /><br />Any help it appreciate... thanks :D<br
/><br/>Alan Jairo Acosta<br /><br /> 

Re: Interval Format

От
Tom Lane
Дата:
Zagato <zagato.gekko@gmail.com> writes:
> I have som SQL that in 8.0.3 do:
> # SELECT '32 hours'::INTERVAL;
>     interval
> -----------------
>  @ 1 day 8 hours
> (1 row)

> And in 8.3.5 do:
> seg_veh2=# SELECT '@ 32 hours'::INTERVAL;
>   interval
> ------------
>  @ 32 hours
> (1 row)

> Why i unable to get my old style of interval,

Because '1 day' isn't really the same thing as '24 hours', at least not
if you live anywhere that they have daylight savings time.

You can probably get the behavior you want by passing the value through
justify_hours(), which does the conversion assuming 1 day == 24 hours.
        regards, tom lane


Re: Interval Format

От
Zagato
Дата:
Hi.... this seems to works... but this will need to rewrite all my sql inPHP that uses interval.... can i make this
defaultin postgres.conf or something similar...<br /><br />Thanks...<br /><br />Alan Jairo Acosta<br /><br /><div
class="gmail_quote">On Fri, Nov 21, 2008 at 9:15 PM, Tom Lane <span dir="ltr"><<a
href="mailto:tgl@sss.pgh.pa.us">tgl@sss.pgh.pa.us</a>></span>wrote:<br /><blockquote class="gmail_quote"
style="border-left:1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div
class="Ih2E3d">Zagato<<a href="mailto:zagato.gekko@gmail.com">zagato.gekko@gmail.com</a>> writes:<br /> > I
havesom SQL that in 8.0.3 do:<br /> > # SELECT '32 hours'::INTERVAL;<br /> >     interval<br /> >
-----------------<br/> >  @ 1 day 8 hours<br /> > (1 row)<br /><br /> > And in 8.3.5 do:<br /> > seg_veh2=#
SELECT'@ 32 hours'::INTERVAL;<br /> >   interval<br /> > ------------<br /> >  @ 32 hours<br /> > (1
row)<br/><br /> > Why i unable to get my old style of interval,<br /><br /></div>Because '1 day' isn't really the
samething as '24 hours', at least not<br /> if you live anywhere that they have daylight savings time.<br /><br /> You
canprobably get the behavior you want by passing the value through<br /> justify_hours(), which does the conversion
assuming1 day == 24 hours.<br /><br />                        regards, tom lane<br /></blockquote></div><br /><br
clear="all"/><br />