sql question
- From: Terry <cooleyt@xxxxxxxxxx>
- Date: Sat, 25 Jun 2005 19:58:24 -0400
using microsoft sql server, D6, ado
I am using the following sql to fetch records for a report
select hrs_emp_clocknum, hrs_status, hrs_startdate, hrs_enddate,
hrs_hours, pad_description
from hrs, padlkup
where ( hrs_emp_clocknum = :emp_clocknum ) and
(hrs_startdate > :startdate and hrs_startdate < :enddate) and
( pad_code = hrs_status )
ORDER BY hrs_status, hrs_startdatethe record has a startdate and enddate field representing a date range. I now need to include records where the startdate parameter value falls within the record startdate, enddate date range, and records where the enddate parameter value falls within the records startdate, enddate date range.
record values
startdate enddate
1. 4/15/04 4/16/04
2. 4/28/04 5/2/04
3. 5/15/04 5/15/04
4. 5/20/04 5/21/04
5. 5/31/04 6/3/04to select records falling within 5/1/04 - 5/31/04
the current sql would select records 3 and 4. I need it also to select 2 and 4.
I tried modifying the where statement to the following to get record 2
where ( hrs_emp_clocknum = :emp_clocknum ) and (
(hrs_startdate < :startdate and hrs_enddate > :startdate) or
(hrs_startdate > :startdate and hrs_startdate < :enddate))and
( pad_code = hrs_status )this added two new parameters named 'startdate' to the paramaters property of the adodataset. when this happened, I thought I was on the wrong track. Is there a way to do this?
Thanks
.
- Follow-Ups:
- Re: sql question
- From: Brian Bushay TeamB
- Re: sql question
- Prev by Date: TADOStoredproc
- Next by Date: txt to dbf
- Previous by thread: TADOStoredproc
- Next by thread: Re: sql question
- Index(es):
Relevant Pages
|