Find overlapping activation Date and deactivation Date(dates should be exclusive)

I am having a teams collection which stores members details.
teamA is having member A11 which is de-active, that means this member A11 can be part of another team but the activationDateTime should be after the deactivationDateTime from teamA value. Team A - member A11 is having deactivation date time- “deactivationDateTime”: “2023-01-06 08:00:00.000Z”
Team B is having member A11 but this member is having “activationDateTime”: “2023-01-05 08:00:00.000Z”,
which is overlapping with the same member in another team. same date overlap happens with members B11 in teamC.
we need to find out such members whose dates are overlapping (dates should be exclusive).

[
  {
    "teamName": "teamA",
    "members": [
      {
        "memberId": "A11",
        "activationDateTime": "2023-01-05 08:00:00.000Z",
        "deactivationDateTime": "2023-01-06 08:00:00.000Z"
      },
      {
        "memberId": "A12",
        "activationDateTime": "2023-01-05 08:00:00.000Z",
        "deactivationDateTime": "2023-01-06 08:00:00.000Z"
      },
      
    ]
  },
  {
    "teamName": "teamB",
    "members": [
      {
        "memberId": "A11",
        "activationDateTime": "2023-01-05 08:00:00.000Z",
        
      },
      {
        "memberId": "B11",
        "activationDateTime": "2023-01-05 08:00:00.000Z",
        "deactivationDateTime": "2023-01-06 08:00:00.000Z"
      },
      {
        "memberId": "B12",
        "activationDateTime": "2023-01-10 08:00:00.000Z",
        
      },
      
    ]
  },
  {
    "teamName": "teamC",
    "members": [
      {
        "memberId": "C11",
        "activationDateTime": "2023-01-05 08:00:00.000Z",
        
      },
      {
        "memberId": "B11",
        "activationDateTime": "2023-01-04 08:00:00.000Z",
        
      },
      
    ]
  },
  
]

@Satyam @Aasawari @Tarun_Gaur @Stennie_X @Ramachandra_Tummala @Jay @Elle_Shwer @Sourabh_Bagrecha @Marcus @Sheila_Doyle
Can u please provide input on this?

@RajeshSNair @Arkadiusz_Borucki @michael_hoeller @Harshit @DerrickChua @TimSantos @GeniusLearner @Kushagra_Kesav @NeNaD @shrey_batra
Please , can I get solution for this.

I am not sure the question is clear.

Realm stores the data you put in it; if the wrong dates are being stored then that’s a coding (coder?) issue, not a Realm issue. On the other hand, if you want to perform a query, then you need to attempt that and include the code your attempted in your question; this is not a code-writing service as there are too many variables.

Most importantly, the question needs to be clear - are you asking how to query for all objects that have the same activationDate and/or deactivationDate?

Please clarify what’s being asked and we’ll take a look.

2 Likes