Date comparison in begin repeat

Dear All,
I have an issue need help to resolve it :
Situation is ,a DATE type variable "Q302" is in repeat group.
There is a variable named "QP" also DATE type variable which will validate Q302 .

  1. If loop is moving multiple times the 2nd loop date should always be greater than -90 days from date of interview and less than 1st loop date .

  2. And 3rd loop date should be less than date mentioned in 2nd loop and greater than -90 days from interview date

And same for every loop....
This link is for reference of tool :

You can use the indexed-repeat() function to lookup the value to the question from a previous repeat group, and (safest) decimal-date-time() to compare dates numerically

To check whether two dates are in a particular chronological order, and the number of days between them:

constraint="decimal-date-time(${date2}) > decimal-date-time(${date1})+90"

And to lookup the date from a different, eg the previous, iteration of a repeat group:

indexed-repeat(${date}, ${mygroup}, position(..)-1)

See Referencing answers in repeats for details.

Armed with this knowledge you should be able to solve your problem... :wink:

Hello,
Need to be more clear on this ;
suppose if we have to collect dates from patient that how many times he have been admitted in hospital in last 3 months.If he says 4 times then we will take last hospitalized date as first then the 2 date will be before the first said date and so ...
e.g I got admitted last on 1 December 2018 then and before it 12 November 2018 and before it 10 October 2018 and before it in 20th may 2018. In this case we will take
1st loop date as : 1 December 2018
2nd loop date as : 12 November 2018
3rd loop date as : 10 October2018
in sequence we have to take dates before last filled dates in 1st loop but we will not take 20th may 2018 in our data because we are collecting only last 3 months admitted history not before that. And one thing more 1 st loop date always be greater than 2nd loop date and 2nd loop date greater than 3rd loop date in sequence...
So, for this we have to create logic in repeat group
As you know only one variable f date is in repeat as"Q302_1". so it will move multiple times as per numbers filled in variable "Q301"