How can I List out the Identity whose start date is between 2023 and 2024?

Hello Everyone
I am trying to List out the users that were
hired between 01/25/2023 - 01/25/2023
orgStatus is Hired
IIQstatus is Active
No HR Account
Active “Active Directory”

I am using Filter.ge(“startDate”,01/25/2023). But it doesn’t return anything.

 QueryOptions qo = new QueryOptions();

  qo.addFilter(Filter.and(Filter.eq("links.application.name", "Active Directory"), Filter.eq("links.disabledAccount", "false")));
  qo.addFilter(Filter.eq("orgStatus", "Hired"));
  qo.addFilter(Filter.ge("startDate", "01/25/2023"));
  qo.addFilter(Filter.eq("iiqStatus", "Active"));
 
  

  List userList = new ArrayList();
  Iterator it = context.search(Identity.class, qo);
  List<Link> links = null;
  while(it.hasNext()){
    Identity id = (Identity) it.next();
    links = id.getLinks();

  }  
  
  for(Link link : links)
  {
    String app = link.getApplicationName();
    if(!app.equals("HR"))
    {
      return "No HR Account";
      
    }
    
    else{
      return "Yes HR Account";
    
    }

  }
Any suggestion

Hi @j1241,

you need to put a Date variable into the filter, like this:

String dateMills= "1706137200000";
Date date = new Date(dateMills);
qo.addFilter(Filter.ge("startDate",date));

you can also parse the date

Hi,

This filter should not be used like this, as you would be searching for identities having one Active directory account and at least one non active account (can be HR or any other account that would match).

If you save dates in identity as strings, then you would have to use something like this

Filter.like("startDate", "/2023", Filter.MatchMode.END);

But this would give you all hires of 2023. You would have to extend it to do then some more filtering on month and day.

Br,
Renad

Hi @j1241,

To fetch identities hired on 01/25/2023, you can use the filter below. If you use the gt() operator, it will return all identities hired after 01/25/2023.

 // Specifying the date "25/01/2023"
            String date = "25/01/2023";
            SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); 

            // Parse the date string to a Date object
            Date startDate = formatter.parse(date);

            // Create a Calendar object to manipulate dates
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(startDate);

            // Set the end of the day (23:59:59) for the specified date
            calendar.set(Calendar.HOUR_OF_DAY, 23);
            calendar.set(Calendar.MINUTE, 59);
            calendar.set(Calendar.SECOND, 59);
            Date endDate = calendar.getTime();

            // Create QueryOptions and add filters
            QueryOptions qo = new QueryOptions();
            qo.addFilter(Filter.gt("created", startDate)); 
            qo.addFilter(Filter.lt("created", endDate)); 

Hello @rquku What would be the best way of searching for identities having one Active directory account and at least one non active account?

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.