# Filtering Date on Report

**URL:** <https://developer.sailpoint.com/discuss/t/filtering-date-on-report/90338>\
**Category:** IIQ Discussion and Questions\
**Tags:** reports, identityiq\
**Created:** [November 20, 2024, 4:54pm UTC](https://developer.sailpoint.com/discuss/t/filtering-date-on-report/90338 "2024-11-20T16:54:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![brunoocarvalho](https://avatars.discourse-cdn.com/v4/letter/b/7ba0ec/32.png) [@brunoocarvalho](https://developer.sailpoint.com/discuss/u/brunoocarvalho)\
**Post date:** [November 20, 2024, 4:54pm UTC](https://developer.sailpoint.com/discuss/t/filtering-date-on-report/90338/1 "2024-11-20T16:54:37Z")

</div>

## Which IIQ version are you inquiring about?

Version 8.3

## Share all details about your problem, including any error messages you may have received

I’m currently developing a report to display the identities that are going to become a leaver. I want to display the identities whose “endDate” is in the next 30 days.

I added the following parameter to the QueryParameters to run a quick test:

```auto
<Parameter property="endDate">
	<QueryScript>
		<Source><![CDATA[
		import sailpoint.object.Filter;
		import java.util.Date;
	
		Date currentDate = new Date();
	
		queryOptions.addFilter(Filter.lt("endDate", currentDate));
		return queryOptions;]]>
		</Source>
	</QueryScript>
</Parameter>

```

From this code, I’m getting the following error:  
`sailpoint.tools.GeneralException: class java.util.Date cannot be cast to class java.lang.String `

Is it possible to use Dates in Filters in order to achieve the desired behavior?

---

<div class="post-metadata">

**Author:** ![pravin\_ranjan](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/pravin_ranjan/32/6771_2.png) [@pravin\_ranjan](https://developer.sailpoint.com/discuss/u/pravin_ranjan)\
**Post date:** [November 20, 2024, 5:12pm UTC](https://developer.sailpoint.com/discuss/t/filtering-date-on-report/90338/2 "2024-11-20T17:12:28Z")

</div>

@brunoocarvalho check this thread : [How can I List out the Identity whose start date is between 2023 and 2024? - IdentityIQ (IIQ) / IIQ Discussion and Questions - SailPoint Developer Community](https://developer.sailpoint.com/discuss/t/how-can-i-list-out-the-identity-whose-start-date-is-between-2023-and-2024/84517/5)

looks like you are storing as string. above link will give some idea.

---

<div class="post-metadata">

**Author:** ![brunoocarvalho](https://avatars.discourse-cdn.com/v4/letter/b/7ba0ec/32.png) [@brunoocarvalho](https://developer.sailpoint.com/discuss/u/brunoocarvalho)\
**Post date:** [November 20, 2024, 6:00pm UTC](https://developer.sailpoint.com/discuss/t/filtering-date-on-report/90338/3 "2024-11-20T18:00:02Z")

</div>

From what I can tell the “endDate” should be in Date format. I just tested the following script, and it shows as Date. Also, the filter doesn’t throw the error in the script.

```auto
import sailpoint.object.Identity;
import sailpoint.object.Filter;
import java.util.Date;

Date d = new Date();
log.error(d);
log.error(d.getClass());

Identity i = context.getObjectByName(Identity.class, "IIQtest02_DEV");
log.error(i.getAttribute("endDate"));
log.error(i.getAttribute("endDate").getClass());

Filter f = Filter.lt("endDate", d);
log.error(f);

```

These are the logs:

 ![image](https://global.discourse-cdn.com/sailpoint/original/3X/c/8/c886e4488e2d3516f3f825577ee9fd02cd3afa90.png)

Shouldn’t I be able to used this filter in the report?

---

<div class="post-metadata">

**Author:** ![brunoocarvalho](https://avatars.discourse-cdn.com/v4/letter/b/7ba0ec/32.png) [@brunoocarvalho](https://developer.sailpoint.com/discuss/u/brunoocarvalho)\
**Post date:** [November 21, 2024, 4:29pm UTC](https://developer.sailpoint.com/discuss/t/filtering-date-on-report/90338/4 "2024-11-21T16:29:06Z")

</div>

From the Advanced Analytics, we can see that the “endDate” is actually stored as a String, with the representation of the endDate in Milliseconds:

![image](https://global.discourse-cdn.com/sailpoint/original/3X/e/2/e29f481a1ba7a11448f5157642df9b93eaf1ff49.png)

For completeness, I leave below the final configuration of the parameter:

```auto
<Parameter property="endDate">
	<QueryScript>
		<Source><![CDATA[
		import java.util.Calendar;
		import java.util.Date;
		import sailpoint.object.Filter;

		Date currentDate = new Date();
		Calendar start = Calendar.getInstance(), end = Calendar.getInstance();
		
		start.setTime(currentDate);
		start.add(Calendar.DATE, -30);

		end.setTime(currentDate);

		queryOptions.addFilter(Filter.ge("endDate", start.getTimeInMillis().toString()));
		queryOptions.addFilter(Filter.le("endDate", end.getTimeInMillis().toString()));

		return queryOptions;]]>
		</Source>
	</QueryScript>
</Parameter>

```

Thanks for the support @pravin_ranjan 🙏

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sailpoint/original/2X/f/f2136700ed5e3703e0b85e02f6be799dacca7735.png) [@system](https://developer.sailpoint.com/discuss/u/system)\
**Post date:** [January 20, 2025, 4:29pm UTC](https://developer.sailpoint.com/discuss/t/filtering-date-on-report/90338/5 "2025-01-20T16:29:24Z")

</div>

Closed on January 20, 2025, 4:29pm UTC

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