Re: Range-Types in 9.2

From: Misa Simic <misa(dot)simic(at)gmail(dot)com>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: Andreas Kretschmer <andreas(at)a-kretschmer(dot)de>, pg-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Range-Types in 9.2
Date: 2012-08-06 19:30:37
Message-ID: CAH3i69k3e3i7ZROPHJer6_Los8QEDyPOp-dkqWDPVfYtedRPgw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I just wonder about scenario in which time range would be usefull? (I mean,
just time - not timestamp...)

We have some scenario where we use time range as settings... Concrete case
is: for each hour employee worked between 20:00 and 08:00 should be paid x,
between 08:00 - 20:00 y... ( stored in table as timestamp range with check
constraint for lower to fixed date, just because of must not overlap
constraint - though could be and 2 time columns...)

Now for actuall working period (timestamp range), we are building dynamic
timestamp ranges, taking date from actual working period and time from
settings, to calculate hours what belongs to x, y rates...

Thanks,

Misa

On Monday, August 6, 2012, Jeff Davis wrote:

> On Fri, 2012-08-03 at 10:42 -0700, Jeff Davis wrote:
> > On Fri, 2012-08-03 at 17:06 +0200, Andreas Kretschmer wrote:
> > > great feature, but i can't find a TIMERANGE, i want to store
> time-ranges, for
> > > instance [10:00:00,16:00:00), how can i do that?
> >
> > CREATE TYPE timerange AS RANGE ( subtype = time );
> >
> > That's the simple answer. I believe we discussed including this as a
> > built-in range type at some point, but decided against it. I can't
> > remember the reason right now.
>
> Time of day is a cycle (I forget who pointed this out), so a limit of
> 24:00:00 is fairly restrictive. It happens that daytime ranges like
> [14:00,15:00) are more common; but it doesn't seem unreasonable to say
> [22:00,02:00) either.
>
> So, an interpretation where time of day has a total order is only useful
> really for a daytime schedule (which is still useful, but perhaps not
> general enough to include in core). We might be able to make it work as
> ranges within a 24-hour cycle, but that will require more thought.
>
> Regards,
> Jeff Davis
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org<javascript:;>
> )
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2012-08-06 21:08:23 Re: How to analyze load average ?
Previous Message Tomas Vondra 2012-08-06 18:30:15 Re: How to analyze load average ?