querying separate date and time columns

C

cporter

I have a query that isn't returning the date and time range that I
want. Basically the boss want s a report of workorders between 7am to
7am (or any other range) on the dates he inputs

The data we have is in the format:

DAYDOWN DAYUP TIMEDOWN TIMEUP MACHID EMPLOYEE ACTION REQUEST1 Comment WONO THD SUBSYS Limited
11/3/1998 11/3/1998 8:00:00 8:20:00 APT-006 KPM PM PM
34743 0.333333333197515 0

I would like to query the table and pull the data between a start/stop
date and time. This gets closest so far:

SELECT WORKORD.MACHID, WORKORD.DAYDOWN, WORKORD.DAYUP,
WORKORD.TIMEDOWN, WORKORD.TIMEUP, WORKORD.EMPLOYEE, WORKORD.ACTION,
WORKORD.REQUEST1, WORKORD.Comment, WORKORD.WONO, WORKORD.THD,
WORKORD.SUBSYS, WORKORD.Limited
FROM WORKORD
WHERE (((WORKORD.DAYUP)>=[Forms]![frmRptDates2]![StartDate] And
(WORKORD.DAYUP)<=[Forms]![frmRptDates2]![StopDate])) OR
(((WORKORD.DAYDOWN) Is Not Null) AND ((WORKORD.DAYUP) Is Null))
ORDER BY WORKORD.MACHID;

This gets the correct date range but not the correct time interval. I
changed the criteria to:

WHERE (((WORKORD.DAYUP)>=[Forms]![frmRptDates2]![StartDate] And
(WORKORD.DAYUP)<=[Forms]![frmRptDates2]![StopDate]) AND
((WORKORD.TIMEDOWN)>=[Forms]![frmRptDates2]![Starttime]) AND
((WORKORD.TIMEUP)<=[Forms]![frmRptDates2]![Stoptime])) OR
(((WORKORD.DAYDOWN) Is Not Null) AND ((WORKORD.DAYUP) Is Null))
ORDER BY WORKORD.MACHID;


This doesn't return the right data. I think I need something like
(daydown+timedown)>=(startdate+starttime) and
(dayup+timeup)<=(stopdate+stoptime) but that doesn't work with the
current table configuration. Is there a way to get the data without
changing the table?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top