Re: Creating a date/time search function in Postgres. - Mailing list pgsql-general

From Daniel Verite
Subject Re: Creating a date/time search function in Postgres.
Date
Msg-id 20060904111227.24401
Whole thread Raw
In response to Creating a date/time search function in Postgres.  ("Sean O'Loughlin" <seanuww@gmail.com>)
List pgsql-general
    Sean O'Loughlin wrote:

> I have a question about how a certain function would look. Basically, what I
> want to do is having something that would take in a 'from' date (day, month,
> year) and a 'to' date (also day, month and year) and then spit back a series
> of records whose timestamps fall between those two dates. How would a basic
> function like that look like? Would I need to have separate integers for the
> day month and year, or is there a date/time object I could use instead? I am
> somewhat new to Postgres, but not SQL altogether.

Maybe you don't really need a function. How about:

test=> SELECT '2006-08-30'::date +
        generate_series(1,'2006-09-04'::date - '2006-08-30'::date);
  ?column?
------------
 2006-08-31
 2006-09-01
 2006-09-02
 2006-09-03
 2006-09-04
(5 rows)

--
 Daniel
 PostgreSQL-powered mail user agent and storage: http://www.manitou-mail.org


pgsql-general by date:

Previous
From: Michael Glaesemann
Date:
Subject: Re: Syntax for converting double to a timestamp
Next
From: Alban Hertroys
Date:
Subject: Re: Training (from Thought provoking...)