pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: joseppi c <joseppic@yahoo.co.uk>
To: pgsql-sql@postgresql.org
Subject: Date ranges + DOW select question
Date: Thu, 15 Jun 2006 11:14:12 +0100 (BST)
Message-ID: <20060615101412.3443.qmail@web25413.mail.ukl.yahoo.com> (raw)

Hi,
I have a table which contains starttime, endtime and
DOW; i.e. a weekly list of times for when a process
must be started and ended.

TABLE: cronTimes
FIELDS: starttime, endtime, dayOfWeek

I have another table which contains date ranges.

TABLE: dateRanges
FIELDS: dateStart, dateEnd

I need to get a list of cronTimes records for a record
in dateRanges and push these to a temporary table.
i.e. tell me which dates are affected by cronTimes.

I have got a little way on this but need some
assistance.

SELECT * FROM cronTimes WHERE
starttime >= '00:00:00' AND endtime <= '23:59:59'
AND dayOfWeek >= (EXTRACT(DOW FROM TIMESTAMP
'2006-06-26')) AND dayOfWeek <=  (EXTRACT(DOW FROM
TIMESTAMP '2006-07-04'));

The problem with the above is that by casting the
dateStart and dateEnd they become numbers between 0
and  
6 which inturn invalidates the < & > as they are
nolonger working on dates, nor a sequence as numbers
can be repeated.

Do I need to generate a sequence of dates somehow so
that each date in the range can be compared to the
cronTimes table (so I can use the 'IN' condition)?

Am I in the realms of plpgsql?

Any advice on the above welcome.

Joseppic.



Send instant messages to your online friends http://uk.messenger.yahoo.com 



view thread (2+ messages)  latest in thread

Message-ID: <20060615101412.3443.qmail@web25413.mail.ukl.yahoo.com>
Permalink:  ../20060615101412.3443.qmail@web25413.mail.ukl.yahoo.com/
Also on:    postgresql.org/message-id/20060615101412.3443.qmail@web25413.mail.ukl.yahoo.com

 · 

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: joseppic@yahoo.co.uk
  Subject: Re: Date ranges + DOW select question
  In-Reply-To: <20060615101412.3443.qmail@web25413.mail.ukl.yahoo.com>

* 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