Question : Patient Days Across Multiple Months

I 'm working on a project that requires calculating patient days by month. Problem is there are some patients that are in the hospital for several months. For instance, 1 patient may be admitted on Mar 27 and discharged on May 15. I want to run a query to give results like this:

Month     Days
Mar         5       <===== Patients are counted on the day of admission, hence 5 days
Apr         30
May        15

Table fields are:
ptName
admitDate
dischargeDate

I'm using MS Access 2003 on Windows XP. Any help is appreciated.

Answer : Patient Days Across Multiple Months

To do this in a query you will have to build a Dates table (DateTbl) containing all possible dates (I've used DayDate as the name of the date field on this table)

You can then do something like...

Select PtName, admitDate, dischargeDate, month(Datestbl.DayDate) as Mth
 from patientstable, Datestbl
where DateTbl.DayDate between admitDate and dischargedate

from there you can convert to a totals query and group on patient and month, and count any field.
Random Solutions  
 
programming4us programming4us