pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
seleting all dates between two dates
4+ messages / 4 participants
[nested] [flat]

* seleting all dates between two dates
@ 2001-06-01 19:09 Jeff Barrett <jbarrett@familynetwork.com>
  2001-06-04 21:39 ` Re: seleting all dates between two dates Hans-Jürgen Schönig <hs@cybertec.at>
  2001-06-06 15:53 ` Re: seleting all dates between two dates Josh Berkus <josh@agliodbs.com>
  2001-06-06 16:31 ` Re: seleting all dates between two dates george young <gry@ll.mit.edu>
  0 siblings, 3 replies; 4+ messages in thread

From: Jeff Barrett @ 2001-06-01 19:09 UTC (permalink / raw)
  To: pgsql-sql

I am interested in a query where I can select all dates between two dates. I
figure I can build a table of all valid dates with a resonable range and
then select from that table, but I would like to use the power of sql to get
the work done without building a date table. Any ideas?

For example:
I want all dates between 05-29-2001 and 06-02-2001
The result set would be:
05-30-2001
05-31-2001
06-01-2001

Thanks for the help.
-Jeff





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: seleting all dates between two dates
  2001-06-01 19:09 seleting all dates between two dates Jeff Barrett <jbarrett@familynetwork.com>
@ 2001-06-04 21:39 ` Hans-Jürgen Schönig <hs@cybertec.at>
  2 siblings, 0 replies; 4+ messages in thread

From: Hans-Jürgen Schönig @ 2001-06-04 21:39 UTC (permalink / raw)
  To: pgsql-sql

Jeff Barrett schrieb:

> I am interested in a query where I can select all dates between two dates. I
> figure I can build a table of all valid dates with a resonable range and
> then select from that table, but I would like to use the power of sql to get
> the work done without building a date table. Any ideas?
>
> For example:
> I want all dates between 05-29-2001 and 06-02-2001
> The result set would be:
> 05-30-2001
> 05-31-2001
> 06-01-2001
>
> Thanks for the help.
> -Jeff

In my opinion there is no reasonable way to solve your problem by using SQL
only
Why don't you use a temporary table created by a simple PL/pgSQL function?

    Hans




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: seleting all dates between two dates
  2001-06-01 19:09 seleting all dates between two dates Jeff Barrett <jbarrett@familynetwork.com>
@ 2001-06-06 15:53 ` Josh Berkus <josh@agliodbs.com>
  2 siblings, 0 replies; 4+ messages in thread

From: Josh Berkus @ 2001-06-06 15:53 UTC (permalink / raw)
  To: Jeff Barrett <jbarrett@familynetwork.com>; pgsql-sql

Jeff,

> I am interested in a query where I can select all dates between two
> dates. I
> figure I can build a table of all valid dates with a resonable range
> and
> then select from that table, but I would like to use the power of sql
> to get
> the work done without building a date table. Any ideas?
> 
> For example:
> I want all dates between 05-29-2001 and 06-02-2001
> The result set would be:
> 05-30-2001
> 05-31-2001
> 06-01-2001

If you browse last week's postings, you will find a thread called "SQL
Date Challenge" with that very issue.  The answer, in short, is that you
can't do it in SQL.  Your choices are to build the reference table, or
to use and external procedural language (such as Perl).

-Josh

______AGLIO DATABASE SOLUTIONS___________________________
                                       Josh Berkus
  Complete information technology      josh@agliodbs.com
   and data management solutions       (415) 565-7293
  for law firms, small businesses        fax 621-2533
    and non-profit organizations.      San Francisco



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: seleting all dates between two dates
  2001-06-01 19:09 seleting all dates between two dates Jeff Barrett <jbarrett@familynetwork.com>
@ 2001-06-06 16:31 ` george young <gry@ll.mit.edu>
  2 siblings, 0 replies; 4+ messages in thread

From: george young @ 2001-06-06 16:31 UTC (permalink / raw)
  To: Jeff Barrett <jbarrett@familynetwork.com>; +Cc: pgsql-sql

On Fri, 1 Jun 2001 15:09:33 -0400
"Jeff Barrett" <jbarrett@familynetwork.com> wrote:
> I am interested in a query where I can select all dates between two dates. I
> figure I can build a table of all valid dates with a resonable range and
> then select from that table, but I would like to use the power of sql to get
> the work done without building a date table. Any ideas?
> 
> For example:
> I want all dates between 05-29-2001 and 06-02-2001
> The result set would be:
> 05-30-2001
> 05-31-2001
> 06-01-2001

You got it almost right already!  Use the "between" operator; *sometimes* SQL *is* intuitive:
E.g. in my database:

select run_name from runs where comp_date between '2001-may-10' and '2001-jun-5';
     run_name     |       comp_date        
------------------+------------------------
 spcsil-103-RP    | 2001-06-04 21:09:35-04
 airtest_0120     | 2001-05-21 20:10:50-04
 spcsil-101-RP    | 2001-05-23 17:44:11-04
 ...

-- 
Your mouse has moved.
Windows NT must be restarted for the change to take effect.
Reboot now?  [OK]



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2001-06-06 16:31 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-06-01 19:09 seleting all dates between two dates Jeff Barrett <jbarrett@familynetwork.com>
2001-06-04 21:39 ` Hans-Jürgen Schönig <hs@cybertec.at>
2001-06-06 15:53 ` Josh Berkus <josh@agliodbs.com>
2001-06-06 16:31 ` george young <gry@ll.mit.edu>

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