Hi all, I'm new here. Great forum btw!
Here's a tough one (at least, for me).
I'm a volunteer at a palliative care center. I'm building a DB to gather statistics on patients occupation.
I want to build a report with a DateDiff that's going to bleed or pour the extra days onto the next month.
An example:
On Jan 1st, Bob is admitted in the center. On March 10th, he dies.
So if we calculate the number of days he stayed, we get 31+28+10=69
Bob stayed at the center for 69 days.
I calculated the DateDiff on the report, grouped by month (the month of the admission) and it's all fine. So I get Bob under Jan, he stayed 69 days. Yeah, cool. But there's only 31 days in Jan. Not so cool.
What I need is the span (I don't even know how to call this), I need the occupancy for each month. This number cannot exceed the number of days in x month. If the patient stays for more than a month, or his stay covers (or crosses) multiple months, I need this to show in the report.
The same example:
Bob stayed 31 days in Jan, so under Jan, we get 31 and not 69 (the initial DateDiff).
Bob stayed 28 days in feb (not a leap year), we get 28.
Bob stayed 10 days in march, so 10.
Do I have to program an algorithm to loop calculate how many days in x month and subtract this from the total occupation (if the number of days figures in multiple months)? Is there another way, something easier? I'm starting to loose sleep because of this...
At this point, anything will help. Thanks all!![]()