pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: D.Sanchez <dsanchezREMOVE@bigpond.com>
To: pgsql-sql@postgresql.org
Subject: Re: two dates
Date: Mon, 17 Mar 2003 09:37:55 +1100
Message-ID: <b52uc2$2b2j$1@news.hub.org> (raw)
References: <3E5B1349.80705@beth.uniforum.org.za>

If you just want to select all entries created between two given dates, the
following query should do it:

SELECT column1, column2, ....
FROM table
WHERE creation_date between to_date('date1','date_format') and
to_date('date2','date_format')
order by creation_date;

This will find all the entries with a creation_date between date1 and date2
and it return the rows sorted by the creation date. You can add additional
selection critirias to the WHERE clause if needed.

David

"mixo" <mixo@beth.uniforum.org.za> wrote in message
news:3E5B1349.80705@beth.uniforum.org.za...
> I have a table which has serveral time stamps include when an entry was
> 'created'.
> Each entry is identified by a unique 'id'. How can I best find entries
> created
> between two dates without going through each day between the two dates?
>
> Currently, going through each day to get the results takes about 23
> minutes for 7 days
> as I have two other criteria for search: roughly I am doing about
> 16*17*n queries,
> where n=days between two dates (for 7 days, 16*17*7 = which a number
> that is
> too big for my liking).
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org





view thread (4+ messages)

Message-ID: <b52uc2$2b2j$1@news.hub.org>
Permalink:  ../b52uc2$2b2j$1@news.hub.org/
Also on:    postgresql.org/message-id/b52uc2$2b2j$1@news.hub.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: dsanchezREMOVE@bigpond.com
  Subject: Re: two dates
  In-Reply-To: <b52uc2$2b2j$1@news.hub.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox