Need query in hours not days

L

Linda RQ

Access 2003. I've been doing pretty well lately making queiris but this one
for some reason, I can't get.....I have a query that has Vent Start Date and
Time and Vent End Date and Time. I made an expression but it is giving me
the answer in days. I need it in hours. I pasted the sql below because I
know you guys can understand the sql better than my descriptions :^ )


VentLOS: Format([ThpyEndDtTm]-[ThpyStDtTm])

SELECT tblPatients.PtLName, tblPatients.PtID, tblPatients.AdmitDtTm,
tblPatients.DCDtTm, tblPatients.AdmitNum, tblPtThpy.PtThpyID,
tblAreaList.AreaName, tblTherapyType.TherapyTypeID,
tblTherapyType.TherapyDesc, tblPtThpy.ThpyStDtTm, tblPtThpy.ThpyEndDtTm,
Format([ThpyEndDtTm]-[ThpyStDtTm]) AS VentLOS
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.AdmitDtTm,
tblPatients.DCDtTm, 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))
ORDER BY tblPatients.AdmitNum;
Thanks,

Linda
 
G

Guest

.....I have a query that has Vent Start Date and Time and Vent End Date and
Time.
But [Vent Start Date and Time] and [Vent End Date and Time] is not in the
query SQL you posted.
 
J

John Spencer

Use the DateDiff function to calculate what you want.

DATEDiff("h",[ThpyStDtTm],[ThpyEndDtTm]) as Hours

Note that counts changes in the hour value so 1:45 to 2:01 gets counted as
one hour. If you need something more accurate then use minutes (n)
DATEDiff("n",[ThpyStDtTm],[ThpyEndDtTm])

AND if you want that in hours and fractions of an hour, divide by 60



--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 

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

Top