Log in

View Full Version : Help needed to create a query



albasel
08-04-2012, 12:09 AM
good day everybody

I have a table which contains a patient_name, sick_type, entering_Date&time and leaving_Date&Time.

I want to do a query that when I enter a date, it shows me all the sick people at that date and how many hours that patient is sick.

For example, if patient A is entering hospital 1/15/2012 7:00 AM and leaving the hospital 1/17/2012 12:00 PM.
So, if i enter the date as 1/16/2012, it shows me that the patient A is 24 hours as a sick
and if I enter the date as 1/17/2012, it shows me that the patient A is 12 hours as a sick

Can any body help me in that>>>

Thanks

I waiting for your great respond....

potski
09-19-2012, 12:19 AM
I created a table called "TBL_SICKNESS" and replaced the &'s in your field names with _'s

Give this a try:
:cool:

SELECT TBL_SICKNESS.patient_name, TBL_SICKNESS.sick_type, TBL_SICKNESS.entering_Date_time, TBL_SICKNESS.leaving_Date_Time, DateDiff("h",[entering_Date_time],[QUERTY_TIME]) AS hrs_since_sick_start, IIf([QUERTY_TIME] Between [entering_date_time] And [leaving_date_time],DateDiff("h",[entering_Date_time],[QUERTY_TIME]),DateDiff("h",[entering_date_time],[leaving_date_time])) AS hrs_spent_ill
FROM TBL_SICKNESS;


It should at least be a start.

Potski