Time based filters
Knit offers two types of time-based filters to cater to diverse user needs.
Firstly, users can filter data based on specific dates, such as selecting data after a certain date , before a certain date and within a defined date range.
Secondly, we provide the flexibility to filter data based on rolling time periods, such as the last "n" days or weeks, months, etc.
Here's a deeper look into how to construct time filters:
Date Based filters
These filter are used when you have to get data relative to given date. For example you need to fetch all jobs created after a certain date. There are three operators you can use for this:
- isGreaterThan
- Used for scenarios if the date in the data model is after the date specified in the filter
- For example, give me only the jobs created after 2023-01-01T00:00:00Z
- isLessThan
- Used for scenarios if the date in the data model is before the date specified in the filter
- For example, give me only the jobs that were created before 2023-01-01T00:00:00Z
- isInBetween
- Used for scenarios if the date in the data model is between the date range specified in the filter
- For example, give me only the jobs that were created after 2023-01-01T00:00:00Z but before 2024-01-01T00:00:00Z
{
"data": "isGreaterThan",
"type": "date_operator",
"left": {
"data": "info.appliedAt",
"type": "key",
"left": null,
"right": null
},
"right": {
"data": "2024-02-01T00:00:00Z",
"type": "value_date",
"left": null,
"right": null
}
}
{
"data": "isGreaterThan",
"type": "date_operator",
"left": {
"data": "info.appliedAt",
"type": "key",
"left": null,
"right": null
},
"right": {
"data": "2024-02-01T00:00:00Z",
"type": "value_date",
"left": null,
"right": null
}
}
{
"data": "isInBetween",
"type": "date_operator",
"left": {
"data": "info.appliedAt",
"type": "key",
"left": null,
"right": null
},
"right": {
"data": "2024-01-01T00:00:00Z,2024-02-01T00:00:00Z",
"type": "value_date",
"left": null,
"right": null
}
}
Important things for date based filter:
- Date must be in ISO-8601 Format and in UTC . Format should be -
yyyy-mm-dd'T'hh:mm:ss'Z'
e.g. 2024-02-01T10:20:40Z- For isInBetween type data should contain comma separated start and end dates in above mentioned format. e.g. 2024-02-01T00:00:00Z,2024-02-20T00:00:00Z
- Filter must have both left and right node where one node is of type
key
and other of typevalue_date
Rolling time based filters
These filters can be used when you want to filter in data for a rolling window. For example, you want to track all applications that occur in the last 7 days.
So, when the sync runs on the 7th of the month, for example, the data from the 1st to the 7th will be tracked. When the sync runs on the 8th, the the data from the 2nd to the 8th will be tracked. Hence, it would be a rolling window from when the sync runs.
The operations you can use for this are:
- rollingDays When day is time unit e.g. last 30 days.
- rollingWeeks When week is time unit e.g. last 3 weeks
- rollingMonths When month is time unit e.g. last 4 months
- rollingYears When year is time unit e.g. last 2 years.
{
"data": "rollingDays",
"type": "date_operator",
"left": {
"data": "info.appliedAt",
"type": "key",
"left": null,
"right": null
},
"right": {
"data": "30",
"type": "value_string",
"left": null,
"right": null
}
}
Important things for rolling time based filters:
- Filter must have both left and right node and one node is of type
key
and other will bevalue_string
which quantifies time unit like how many days / weeks / months data is needed.
Updated 10 months ago