There might be a prettier way to do this, but this is my first idea...
Create one formula for each month and insert it in your detail based on these examples for the first 6 months of 2003.
Name : {@Jan_2003}
Formula : IF ((Year ({MonthCalc_txt.StartEffDate}) = 2003 AND Month ({MonthCalc_txt.StartEffDate}) = 1)
OR (Year ({MonthCalc_txt.EndEffDate}) = 2003 AND Month ({MonthCalc_txt.EndEffDate}) = 1)) THEN 1
ELSE
IF ((Date((Year({MonthCalc_txt.StartEffDate})),(Month ({MonthCalc_txt.StartEffDate})),1) <= Date (2003,1,1))
AND (Date((Year({MonthCalc_txt.EndEffDate})),(Month ({MonthCalc_txt.EndEffDate})),1) >= Date (2003,1,1))) THEN 1
ELSE 0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Name : {@Feb_2003}
Formula : IF ((Year ({MonthCalc_txt.StartEffDate}) = 2003 AND Month ({MonthCalc_txt.StartEffDate}) = 2)
OR (Year ({MonthCalc_txt.EndEffDate}) = 2003 AND Month ({MonthCalc_txt.EndEffDate}) = 2)) THEN 1
ELSE
IF ((Date((Year({MonthCalc_txt.StartEffDate})),(Month ({MonthCalc_txt.StartEffDate})),1) <= Date (2003,2,1))
AND (Date((Year({MonthCalc_txt.EndEffDate})),(Month ({MonthCalc_txt.EndEffDate})),1) >= Date (2003,2,1))) THEN 1
ELSE 0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Name : {@Mar_2003}
Formula : IF ((Year ({MonthCalc_txt.StartEffDate}) = 2003 AND Month ({MonthCalc_txt.StartEffDate}) = 3)
OR (Year ({MonthCalc_txt.EndEffDate}) = 2003 AND Month ({MonthCalc_txt.EndEffDate}) = 3)) THEN 1
ELSE
IF ((Date((Year({MonthCalc_txt.StartEffDate})),(Month ({MonthCalc_txt.StartEffDate})),1) <= Date (2003,3,1))
AND (Date((Year({MonthCalc_txt.EndEffDate})),(Month ({MonthCalc_txt.EndEffDate})),1) >= Date (2003,3,1))) THEN 1
ELSE 0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Name : {@Apr_2003}
Formula : IF ((Year ({MonthCalc_txt.StartEffDate}) = 2003 AND Month ({MonthCalc_txt.StartEffDate}) = 4)
OR (Year ({MonthCalc_txt.EndEffDate}) = 2003 AND Month ({MonthCalc_txt.EndEffDate}) = 4)) THEN 1
ELSE
IF ((Date((Year({MonthCalc_txt.StartEffDate})),(Month ({MonthCalc_txt.StartEffDate})),1) <= Date (2003,4,1))
AND (Date((Year({MonthCalc_txt.EndEffDate})),(Month ({MonthCalc_txt.EndEffDate})),1) >= Date (2003,4,1))) THEN 1
ELSE 0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Name : {@May_2003}
Formula : IF ((Year ({MonthCalc_txt.StartEffDate}) = 2003 AND Month ({MonthCalc_txt.StartEffDate}) = 5)
OR (Year ({MonthCalc_txt.EndEffDate}) = 2003 AND Month ({MonthCalc_txt.EndEffDate}) = 5)) THEN 1
ELSE
IF ((Date((Year({MonthCalc_txt.StartEffDate})),(Month ({MonthCalc_txt.StartEffDate})),1) <= Date (2003,5,1))
AND (Date((Year({MonthCalc_txt.EndEffDate})),(Month ({MonthCalc_txt.EndEffDate})),1) >= Date (2003,5,1))) THEN 1
ELSE 0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Name : {@June_2003}
Formula : IF ((Year ({MonthCalc_txt.StartEffDate}) = 2003 AND Month ({MonthCalc_txt.StartEffDate}) = 6)
OR (Year ({MonthCalc_txt.EndEffDate}) = 2003 AND Month ({MonthCalc_txt.EndEffDate}) = 6)) THEN 1
ELSE
IF ((Date((Year({MonthCalc_txt.StartEffDate})),(Month ({MonthCalc_txt.StartEffDate})),1) <= Date (2003,6,1))
AND (Date((Year({MonthCalc_txt.EndEffDate})),(Month ({MonthCalc_txt.EndEffDate})),1) >= Date (2003,6,1))) THEN 1
ELSE 0
The data will return like this...
Patient StartEffDate EndEffDate Jan_2003 Feb_2003 Mar_2003 Apr_2003 May_2003 June_2003
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
A 01/01/2003 03/15/2003 1 1 1 0 0 0
B 01/01/2003 12/31/9999 1 1 1 1 1 1
C 05/01/2003 05/31/2003 0 0 0 0 1 0
D 06/15/2003 08/15/2003 0 0 0 0 0 1
E 06/01/2002 12/31/9999 1 1 1 1 1 1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -