# Compare dates in filter

**URL:** https://connective.celigo.com/t/compare-dates-in-filter/1139
**Category:** Integrator.io
**Tags:** filter, error-handling, ui-ux
**Created:** [September 8, 2021, 9:00pm UTC](https://connective.celigo.com/t/compare-dates-in-filter/1139 "2021-09-08T21:00:32Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![chrisharper](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/chrisharper/32/4443_2.png) [@chrisharper](https://connective.celigo.com/u/chrisharper)
#### Post date: [September 8, 2021, 9:00pm UTC](https://connective.celigo.com/t/compare-dates-in-filter/1139/1 "2021-09-08T21:00:32Z")

</div>

How can I use an arbitrary date in the Argument #2 field for this filter expression? This produces an error message: "Message: Argument #2 for operation greaterthanequals is a different data type: string." I have selected Data Type "Date Time" from the settings box for Argument #2 with no luck.

 ![5301043caa20740200000001-a086820c0ffd4e83aba75118dfd4f298.png](https://us1.discourse-cdn.com/flex001/uploads/celigo/original/2X/0/0b0f74952a23a559e307ba3eec42c6d8daf2ff23.png)

---

<div class="post-metadata">

### Author: ![courtneyjordan](https://avatars.discourse-cdn.com/v4/letter/c/b2d939/32.png) [@courtneyjordan](https://connective.celigo.com/u/courtneyjordan)
#### Post date: [September 13, 2021, 7:16pm UTC](https://connective.celigo.com/t/compare-dates-in-filter/1139/2 "2021-09-13T19:16:42Z")

</div>

Hi @chrishunter,

Sorry for the delay on this. We are looking into it to determine if this is an issue we need to fix. Will hopefully have this info by tomorrow. Thanks so much for letting us know that you've run into this issue, and please continue to let us know what else we can do to improve your experience!

---

<div class="post-metadata">

### Author: ![courtneyjordan](https://avatars.discourse-cdn.com/v4/letter/c/b2d939/32.png) [@courtneyjordan](https://connective.celigo.com/u/courtneyjordan)
#### Post date: [September 14, 2021, 9:08pm UTC](https://connective.celigo.com/t/compare-dates-in-filter/1139/3 "2021-09-14T21:08:41Z")

</div>

Hi @chrishunter,

First, set your data type to Expression if you haven't already. To do so, click the gear icon next to the last field (hover to the right of the field to display it).

 ![5301043caa20740200000001-d657ac6406f44f1780d30ffbef8bf07a.png](https://us1.discourse-cdn.com/flex001/uploads/celigo/original/2X/a/af7f0756b526763342b22182dc198ed4ceeb9490.png)

Then, set your filters like this:

```
record.lastExportDateTime is less-than ["epochtime", "2021-09-07T00:00:000Z"]
```

Please let us know if that works for you! Thanks!

---

<div class="post-metadata">

### Author: ![danielp](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/danielp/32/4423_2.png) [@danielp](https://connective.celigo.com/u/danielp)
#### Post date: [September 22, 2021, 3:10pm UTC](https://connective.celigo.com/t/compare-dates-in-filter/1139/4 "2021-09-22T15:10:50Z")

</div>

@courtneyjordan Is there a way to compare two dates (a last updated date and the current date/time for example) and get a difference in minutes in a filter? Much like the dateAdd in handlebars but for a filter?

---

<div class="post-metadata">

### Author: ![tomsantiago](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/tomsantiago/32/7158_2.png) [@tomsantiago](https://connective.celigo.com/u/tomsantiago)
#### Post date: [October 7, 2021, 7:23pm UTC](https://connective.celigo.com/t/compare-dates-in-filter/1139/5 "2021-10-07T19:23:38Z")

</div>

Hi @danielp,

Filter syntax via the filter editor is very limited and uses a cumbersome syntax:

[https://docs.celigo.com/hc/en-us/articles/360025927811-Apply-filters#Supportedexpressions](https://docs.celigo.com/hc/en-us/articles/360025927811-Apply-filters#Supportedexpressions)

Orion Abrams (one of our Senior Engineers), suggested you instead use a preSave page hook and use something like this to get what I think you are looking for:

```
function preSavePageFunction(options) {
    const records = options.data;
    for (let i = records.length - 1; i >= 0; i--) {
        let dataRec = records[i];
        //add date comparison here
        if (dataRec.dateModifiedByUser) {
            let date1 = new Date(options.lastExportDateTime);
            let date2 = new Date(dataRec.dateModifiedByUser);
            if (date2.getTime() < date1.getTime()) {
                options.data.splice(i, 1);
            }
        }
    }
    return {
        data: options.data,
        errors: options.errors
    }
}
```

---

<div class="post-metadata">

### Author: ![Stein\_Chu](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@Stein\_Chu](https://connective.celigo.com/u/Stein_Chu)
#### Post date: [April 18, 2025, 10:48am UTC](https://connective.celigo.com/t/compare-dates-in-filter/1139/7 "2025-04-18T10:48:38Z")

</div>

In case this might be helpful to somebody that really needs to do the expression like in my case, I am doing it in the IA so I don't have an option to script it.

 ![This image shows a user interface for defining an input filter with JSON data and a rule that checks the time difference between cancellation and creation records. (Captioned by AI)](https://us1.discourse-cdn.com/flex001/uploads/celigo/original/2X/b/ba2760129786c81de9a2bafed24356f6937f82c3.png)

---

<div class="post-metadata">

### Author: ![Stein\_Chu](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@Stein\_Chu](https://connective.celigo.com/u/Stein_Chu)
#### Post date: [April 18, 2025, 12:15pm UTC](https://connective.celigo.com/t/compare-dates-in-filter/1139/8 "2025-04-18T12:15:29Z")

</div>

might actually be more appropriate here:

> [@Date Filter Question](https://connective.celigo.com/t/date-filter-question/258):
>
> I have been trying to set a date in the output filter for my export. I have set the field to "expression" and am using the correct handlebar (I think) so that it looks at the current date, but am not having much success and cant figure out what part I am not doing correctly. I think its simple, but just can't seem to get it! Any help is always appreciated!
