R
red skelton via AccessMonster.com
Good Afternoon,
I am having a problem with a query and will first thank everyone that has
helped so far. My problem is that the query isn't pulling the correct
information I need. I think, instead of looking at just the data entered in
my between date, it is looking at the entire table as the times it pulls are
in the table in a different day. My query is as follows:
MinutesGap: DateDiff("n",[Table1].[TimeOutOfOR],(SELECT Min(Dupe.[OR Start])
FROM Table1 AS Dupe WHERE Dupe.[OR Start]>= Table1.TimeOutOfOR))
and
NextStart: ((SELECT Min(Dupe.[OR Start]) FROM Table1 AS Dupe WHERE Dupe.[OR
Start]>= Table1.TimeOutOfOR))
my SQL is:
SELECT Table1.Name, Table1.Date, Table1.SSN, Table1.[OR#], Table1.Surgeon,
Table1.Procedure, Table1.[UCA Code], Table1.[OR Start], Table1.TimeOutOfOR,
DateDiff("n",[Table1].[TimeOutOfOR],(SELECT Min(Dupe.[OR Start]) FROM Table1
AS Dupe WHERE Dupe.[OR Start]>= Table1.TimeOutOfOR)) AS MinutesGap, ((SELECT
Min(Dupe.[OR Start]) FROM Table1 AS Dupe WHERE Dupe.[OR Start]>= Table1.
TimeOutOfOR)) AS NextStart
FROM Table1
WHERE (((Table1.Date) Between [Enter Date From] And [Enter Date To:]) AND (
(Table1.[OR#])=[Enter OR#]))
ORDER BY Table1.TimeOutOfOR;
What I'm trying to do is see how much time passes between the TimeOutOfOR and
the next OR Start time. For example, my first TimeOutOfOR is 8:15 and my
next OR Start time is 8:30 the Minutesgap should be 15 minutes and the next
start time of 8:30, but I get a MinuteGap of 1 minute and a NextStart of 8:31
(which is an OR start time but on another day)
I hope I have not totally confused everyone but any help to make this query
just look at the between time for the next OR Start time and not the entire
table.
Thanks for your time,
Red
I am having a problem with a query and will first thank everyone that has
helped so far. My problem is that the query isn't pulling the correct
information I need. I think, instead of looking at just the data entered in
my between date, it is looking at the entire table as the times it pulls are
in the table in a different day. My query is as follows:
MinutesGap: DateDiff("n",[Table1].[TimeOutOfOR],(SELECT Min(Dupe.[OR Start])
FROM Table1 AS Dupe WHERE Dupe.[OR Start]>= Table1.TimeOutOfOR))
and
NextStart: ((SELECT Min(Dupe.[OR Start]) FROM Table1 AS Dupe WHERE Dupe.[OR
Start]>= Table1.TimeOutOfOR))
my SQL is:
SELECT Table1.Name, Table1.Date, Table1.SSN, Table1.[OR#], Table1.Surgeon,
Table1.Procedure, Table1.[UCA Code], Table1.[OR Start], Table1.TimeOutOfOR,
DateDiff("n",[Table1].[TimeOutOfOR],(SELECT Min(Dupe.[OR Start]) FROM Table1
AS Dupe WHERE Dupe.[OR Start]>= Table1.TimeOutOfOR)) AS MinutesGap, ((SELECT
Min(Dupe.[OR Start]) FROM Table1 AS Dupe WHERE Dupe.[OR Start]>= Table1.
TimeOutOfOR)) AS NextStart
FROM Table1
WHERE (((Table1.Date) Between [Enter Date From] And [Enter Date To:]) AND (
(Table1.[OR#])=[Enter OR#]))
ORDER BY Table1.TimeOutOfOR;
What I'm trying to do is see how much time passes between the TimeOutOfOR and
the next OR Start time. For example, my first TimeOutOfOR is 8:15 and my
next OR Start time is 8:30 the Minutesgap should be 15 minutes and the next
start time of 8:30, but I get a MinuteGap of 1 minute and a NextStart of 8:31
(which is an OR start time but on another day)
I hope I have not totally confused everyone but any help to make this query
just look at the between time for the next OR Start time and not the entire
table.
Thanks for your time,
Red