Peter Stampfli
Peter Stampfli

Reputation: 21

In Directus Flow to Read-Data Operation: how to extract the month of now$ in a filter

Use Case: I have a collection with consulant with a field birhdate.

Now I want to create a flow to read all consultant who have birthday this month.

{
  "collection": "Consultant",
  "query": {
    "filter": {
      "month(birthdate)": {
        "_eq": "month($now)"
      }
    }
  }
}

Does not work!!!

When I hardcode the month it works nicely

{
  "collection": "Consultant",
  "query": {
    "filter": {
      "month(birthdate)": {
        "_eq": "7"
      }
    }
  }
}

Any suggenstions?

extract current month out of $now in a filter

Upvotes: 2

Views: 1776

Answers (2)

Ravindra Thadani
Ravindra Thadani

Reputation: 1

Although certain Operations in Flows use filter rules, dynamic variables are not available in Flows.

Upvotes: 0

hamilton.lima
hamilton.lima

Reputation: 1918

From the Directus documentation, https://docs.directus.io/reference/filter-rules.html#dynamic-variables, you can see:

Although certain Operations in Flows use filter rules, dynamic variables are not available in Flows.

I would create an "Run Script" Operation to extract the month, and use it your filter. see https://docs.directus.io/app/flows/operations.html#run-script

Upvotes: 1

Related Questions