Re: date range query help

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: date range query help
Date: 2008-11-20 11:49:16
Message-ID: 20081120114916.GJ2459@frubble.xen.chris-lamb.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-novice pgsql-sql

On Thu, Nov 20, 2008 at 01:10:41PM +1100, novice wrote:
> select * from mobile_custodian;
>
> custodian_id | user_id | issue_date | return_date | mobile_no
> --------------+---------+------------+-------------+-------------
> 4 | Ben | 2008-10-11 | 2008-10-13 | 09455225998
> 5 | Josh | 2008-10-15 | | 09455225998

I sometimes find it easier to store ranges like this with having the
open ends at infinity. This is easier with timestamps as they have
magic 'infinity' values in PG (both positive and negative). Values of
date type don't have any special values like this which makes things a
bit more awkward.

I haven't seen it posted to the list for a while; but there's a nice
old book titled "Developing Time Oriented Database Applications in SQL"
that's now out of print but is available as a PDF.

http://www.cs.arizona.edu/~rts/tdbbook.pdf

Sam

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message WireSpot 2008-11-20 11:53:58 join with redundant results VS simpler join plus multiple selects
Previous Message Marcus Engene 2008-11-20 11:45:53 Re: where in (select array)

Browse pgsql-novice by date

  From Date Subject
Next Message Frank Bax 2008-11-20 13:22:25 Re: [SQL] date range query help
Previous Message Raymond C. Rodgers 2008-11-20 05:42:42 Re: date range query help

Browse pgsql-sql by date

  From Date Subject
Next Message Frank Bax 2008-11-20 13:22:25 Re: [SQL] date range query help
Previous Message Craig Ringer 2008-11-20 11:29:55 Re: UPDATE and DELEte with a lot of register is to slow...