If I understand correctly, you want to:
(a) find all patients participating in the program during the report period - either fully or partially;
(b) for the partially participating patients, calculate the portion of their particiating period that falls in the reported period.
If so, I'd suggest you use two globalDate fields, gReportStart and gReportEnd to hold the reported range. Then you can calculate the participating portion as:
Max ( Min ( EndDate ; gReportEnd ) - Max ( StartDate ; gReportStart ) ; 0 )
To find the relevant patients:
Enter Find Mode 
Set Field [ StartDate ; "≤" & gReportEnd ]
Set Field [ EndDate ; "≥" & gReportStart ]
Perform Find 
Yea, you are right in what i am trying to do, well done.
But, as i said, i am a slow learner and am not really sure whow to implement your reply, but i am going to give it a try.
If it helps, am i able to send / post a clone of what i have?
I do not expect anyone to add my fields for me, but as i am so slow i would appreciate it if you could have a look so that i don't waste a whole lot of time.
It almost works.
The patients that fall into the partial range do have their days on the program calculated, but they are all 1 day short.
i.e. if a patient finishes on 1 July the calculated days = 0 when it should be 1, and a patient thatfinished the program on 19 August should have 50 days but is calc'ed at 49.
Is there a simple fix?
Can a script be written to catch all patients in the the one report?
Or, am i forever going to have to perform 2 separate searches??
Our hospital would like these reports monthly internally, but reported nationally 6 monthly.
Ignore most of my last.
It does work in one search, but the calc'ed number is still out by -1 on each of the subset of 4 patients that i have now found.
The problem was that i didn't read your solution propoerly, i.e. all my fault, Soz!
So, is there a simple fix?
If your original calculation was =
EndDate - StartDate + 1
i.e. including both StartDate and EndDate, then you should add 1 in the current calculation as well:
Max ( Min ( EndA ; EndB ) - Max ( StartA ; StartB ) + 1 ; 0 )
Using FM 10.0v1
The average is the (arithmetic) mean.
Calculating the median of the found set is a bit more problematic, because records must be sorted by the value for this. If your report requires a different sort order, then you need a script to (a) sort by the value, (b) calculate the median and write the result into a global field, and (c) sort the records as required by the report.
Once records are sorted by the value, the median is =
Let ( [ n = Get (FoundCount) ; mid = Div ( n ; 2 ) ] ; Case ( Mod ( n ; 2 ) ; GetNthRecord ( Value ; mid + 1 ) ; .5 * ( GetNthRecord ( Value ; mid ) + GetNthRecord ( Value ; mid + 1 ) ) ) )
You are a legend!!
You should be on a payroll for your knowledge.
Thank you, eM