L
Linda RQ
Hi Everyone,
Access 2003. I use the query grid to create my query but pasted the sql
below so if the answer can be directed so I can use the grid, that would
help.
I need my query to display a list of patients who were on a therapy 70 or 81
in the picu. It is working great except, I entered these dates...Start Date
7/1/07, End Date 9/30/07. The problem is, it is not showing 2 records who
have end dates of 9/30/07. If I type in Start Date 7/1/07 and End Date
10/1/07 they are included on that. It wouldn't make sense to the user to
type in 10/1/07 because they are looking for dates between 7/1 and 9/30.
Thanks,
Linda
PARAMETERS [Enter Start Date] DateTime, [Enter End Date] DateTime;
SELECT tblPatients.PtLName, tblPatients.PtID, tblPatients.AdmitNum,
tblPtThpy.PtThpyID, tblAreaList.AreaName, tblTherapyType.TherapyTypeID,
tblTherapyType.TherapyDesc, tblPtThpy.ThpyStDtTm, tblPtThpy.ThpyEndDtTm,
IIf([ThpyStDtTm]<[Enter Start Date],[Enter Start Date],[ThpyStDtTm]) AS
CalcStartDate, Nz([ThpyEndDtTm],[Enter End Date]) AS CalcEndDate,
Nz([ThpyEndDtTm],[Enter End Date])-IIf([ThpyStDtTm]<[Enter Start
Date],[Enter Start Date],[ThpyStDtTm]) AS VentLOSDays, [VentLOSDays]*24 AS
VentLOSHours
FROM (tblPatients INNER JOIN (tblAreaList INNER JOIN tblPtLocation ON
tblAreaList.AreaID=tblPtLocation.AreaID_fk) ON
tblPatients.PtID=tblPtLocation.PtID_fk) INNER JOIN (tblTherapyType INNER
JOIN tblPtThpy ON tblTherapyType.TherapyTypeID=tblPtThpy.ThpyTypeID_fk) ON
tblPatients.PtID=tblPtThpy.PtID_fk
GROUP BY tblPatients.PtLName, tblPatients.PtID, tblPatients.AdmitNum,
tblPtThpy.PtThpyID, tblAreaList.AreaName, tblTherapyType.TherapyTypeID,
tblTherapyType.TherapyDesc, tblPtThpy.ThpyStDtTm, tblPtThpy.ThpyEndDtTm
HAVING (((tblAreaList.AreaName)="picu") AND
((tblTherapyType.TherapyTypeID)=70 Or (tblTherapyType.TherapyTypeID)=81) AND
((Nz([ThpyEndDtTm],[Enter End Date])) Between [Enter Start Date] And [Enter
End Date]))
ORDER BY tblPatients.PtLName;
Access 2003. I use the query grid to create my query but pasted the sql
below so if the answer can be directed so I can use the grid, that would
help.
I need my query to display a list of patients who were on a therapy 70 or 81
in the picu. It is working great except, I entered these dates...Start Date
7/1/07, End Date 9/30/07. The problem is, it is not showing 2 records who
have end dates of 9/30/07. If I type in Start Date 7/1/07 and End Date
10/1/07 they are included on that. It wouldn't make sense to the user to
type in 10/1/07 because they are looking for dates between 7/1 and 9/30.
Thanks,
Linda
PARAMETERS [Enter Start Date] DateTime, [Enter End Date] DateTime;
SELECT tblPatients.PtLName, tblPatients.PtID, tblPatients.AdmitNum,
tblPtThpy.PtThpyID, tblAreaList.AreaName, tblTherapyType.TherapyTypeID,
tblTherapyType.TherapyDesc, tblPtThpy.ThpyStDtTm, tblPtThpy.ThpyEndDtTm,
IIf([ThpyStDtTm]<[Enter Start Date],[Enter Start Date],[ThpyStDtTm]) AS
CalcStartDate, Nz([ThpyEndDtTm],[Enter End Date]) AS CalcEndDate,
Nz([ThpyEndDtTm],[Enter End Date])-IIf([ThpyStDtTm]<[Enter Start
Date],[Enter Start Date],[ThpyStDtTm]) AS VentLOSDays, [VentLOSDays]*24 AS
VentLOSHours
FROM (tblPatients INNER JOIN (tblAreaList INNER JOIN tblPtLocation ON
tblAreaList.AreaID=tblPtLocation.AreaID_fk) ON
tblPatients.PtID=tblPtLocation.PtID_fk) INNER JOIN (tblTherapyType INNER
JOIN tblPtThpy ON tblTherapyType.TherapyTypeID=tblPtThpy.ThpyTypeID_fk) ON
tblPatients.PtID=tblPtThpy.PtID_fk
GROUP BY tblPatients.PtLName, tblPatients.PtID, tblPatients.AdmitNum,
tblPtThpy.PtThpyID, tblAreaList.AreaName, tblTherapyType.TherapyTypeID,
tblTherapyType.TherapyDesc, tblPtThpy.ThpyStDtTm, tblPtThpy.ThpyEndDtTm
HAVING (((tblAreaList.AreaName)="picu") AND
((tblTherapyType.TherapyTypeID)=70 Or (tblTherapyType.TherapyTypeID)=81) AND
((Nz([ThpyEndDtTm],[Enter End Date])) Between [Enter Start Date] And [Enter
End Date]))
ORDER BY tblPatients.PtLName;