View Single Post

   
  #3 (permalink)  
Old 03-01-2008, 03:49 PM
WPW07
 
Posts: n/a
Default Re: Help with SQL Syntax

On Feb 28, 10:51 am, Captain Paralytic <paul_laut...@yahoo.com> wrote:
> On 28 Feb, 15:18, WPW07 <wwisnie...@gmail.com> wrote:
>
>
>
> > Hello,

>
> > I've got a PHP form that returns results from a MySQL table [tasks]
> > based on three parameters:
> > task_resource
> > begin_date
> > end_date

>
> > Here is my code in the record set dialog box:

>
> > SELECT *
> > FROM tasks
> > WHERE (task_resource = varName) AND (begin_date BETWEEN varBeginDate
> > AND varEndDate OR end_date BETWEEN varBeginDate AND varEndDate)
> > ORDER BY tasks.begin_date

>
> > I thought it was working fine until I ran into a problem. The SQL
> > statement doesn't work if I want to see only those tasks begun and
> > completed on the same day. For example, I entered begin_date 02/22/08
> > to end_date 02/22/08 because I only want to see tasks started AND
> > completed on that date. But my SQL is set up (with the "OR") so that
> > it's returning tasks with a begin_date of 02/21/08 and end_date of
> > 02/22/08.

>

Thank you for your reply. I did try WHERE begindate = x AND enddate =
x But the problem is that if there isn't task that meets those exact
data parameters nothing gets returned, where as if the begin date is
between x and y and the end date is between x and y, results do get
returned.

> > How can I correct my SQL? Not sure how to do this if I take out the OR
> > condition.

>
> > Thank you.

>
> Could you possibly use an internationally recognised date format when
> discusing things here, it makes life much simpler.
>
> Now, you have explained that you want to be able to see only tasks
> begun and completed on the same date. This is of course trivial:
> WHERE begindate = x AND enddate = x
>
> But you haven't explained whatelse this expression will be required to
> produce.


Reply With Quote