| From: | Brent Wood <b(dot)wood(at)niwa(dot)co(dot)nz> |
|---|---|
| To: | Listmail <lists(at)peufeu(dot)com> |
| Cc: | pgsql-general(at)postgresql(dot)org, kleptog(at)svana(dot)org |
| Subject: | Re: Temporal Units |
| Date: | 2007-04-30 00:57:14 |
| Message-ID: | 46353EEA.7040708@niwa.co.nz |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Listmail wrote:
> On Sun, 29 Apr 2007 22:33:37 +0200, Rich Shepard
> <rshepard(at)appl-ecosys(dot)com> wrote:
>
>> On Sun, 29 Apr 2007, Martijn van Oosterhout wrote:
>>
>>> Then I'm afraid you havn't indicated your requirements properly. All
>>> I can
>>> see is that the interval type does exactly what you want. It can store
>>> days, weeks, months or any combination thereof. You can multiply
>>> them and
>>> add them to dates and all works as expected.
>>
>> How does one define 'shift' with intervals? 0.33 DAY?
>
If I'm following this correctly, then interval & extract timepart can be
used to provide all the required functionality:
If you know what hours your shifts (periods) cover, and you want to
check that you have a value for that shift today (ignoring for now
issues with shifts only on 5 day working weeks & holidays, ...) then you
can do something like:
if (select count(*) from table
where extract day = today
and extract hour (now) >= extract hour from (shift start timestamp)
and extract hour <= extract hour from(shift start timestamp +
interval shift length)
) =0
then a value is missing
So for any check, you want to ensure you have no periods without a
value, which can only be done at the end of each period.
If you have a table defining each period, a cron job can run (for
example) hourly, identifying any periods which ended in the last hour
and did not have a value. Or periods about to end in the next "interval"
which do not yet have a value, to prompt before the period ends.
The trickier part is how to specify your periods, and which
days/hours/months/etc are included. Each period needs to be defined by
data which allows a start and a finish date/time expressed in a generic
way which is relative to "now" to be determined. So for any "now" we can
evaluate which periods are about to end or have just ended.
Cheers,
Brent Wood
| From | Date | Subject | |
|---|---|---|---|
| Next Message | FAST PostgreSQL | 2007-04-30 05:10:50 | Re: SOS, help me please, one problem towards the postgresql developement on windows |
| Previous Message | chrisj | 2007-04-29 22:35:48 | Re: tsearch2 and english locale on Debian - english.0 english.1 |