# How to filter date in a custom field?

**URL:** <https://community.forestadmin.com/t/how-to-filter-date-in-a-custom-field/6824>\
**Category:** Help me!\
**Created:** [November 10, 2023, 4:34am UTC](https://community.forestadmin.com/t/how-to-filter-date-in-a-custom-field/6824 "2023-11-10T04:34:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Simon\_Chen](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/simon_chen/32/6384_2.png) [@Simon\_Chen](https://community.forestadmin.com/u/Simon_Chen)\
**Post date:** [November 10, 2023, 4:34am UTC](https://community.forestadmin.com/t/how-to-filter-date-in-a-custom-field/6824/1 "2023-11-10T04:34:02Z")

</div>

![image](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/f/fdaf587a500840f0a2051ac7a11ade770a2b6c87.png)  
This is my custom field with the data type of Date, is it possible to make it filterable like the image below? where the date is able to select from the calendar.

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/8/88f65b5f6a1e6f41c92cf69db7366d3ec048b6fc.png)

Project name: Durian  
Team name: Operations  
Environment name: Production  
Agent (forest package) name & version: “@forestadmin/agent”: “^1.16.2”,  
Database type: PostgreSQL

---

<div class="post-metadata">

**Author:** ![shohanr](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/shohanr/32/4999_2.png) [@shohanr](https://community.forestadmin.com/u/shohanr)\
**Post date:** [November 10, 2023, 2:31pm UTC](https://community.forestadmin.com/t/how-to-filter-date-in-a-custom-field/6824/2 "2023-11-10T14:31:25Z")

</div>

Hi @Simon_Chen ,

This is possible but you will have to override each of the operator for the filter function.  
Here is a snippet to show you how to override one operator:

```javascript
    houses
      .addField("dateOfNow", {
        columnType: "Date",
        dependencies: ["id"],
        getValues: (records) => records.map(() => new Date()),
      })
      .replaceFieldOperator("dateOfNow", "Equal", (value) => {
        return {
          aggregator: "And",
          conditions: [
            {
              field: "example",
              operator: "Equal",
              value: new Date(value),
            },
          ],
        };
      });

```

Here is a second snippet with all the operators:

```javascript
const basicOperators = ["Blank", "Equal", "Missing", "NotEqual", "Present"];
const dateOperators = [
  "Today",
  "Yesterday",
  "PreviousXDaysToDate",
  "PreviousWeek",
  "PreviousWeekToDate",
  "PreviousMonth",
  "PreviousMonthToDate",
  "PreviousQuarter",
  "PreviousQuarterToDate",
  "PreviousYear",
  "PreviousYearToDate",
  "Past",
  "Future",
  "PreviousXDays",
  "Before",
  "After",
  "BeforeXHoursAgo",
  "AfterXHoursAgo",
];
const timeOperators = ["LessThan", "GreaterThan"];
  [...basicOperators, ...timeOperators, ...dateOperators].forEach(
    (operator) => {
      houses.replaceFieldOperator("dateOfNow", operator, (value) => {});
    }
  );

```

You will have to implement the filtering process for each operator that you want to use.

Best regards,

Shohan
