Problem fetching overdue tasks with due_at.before in advanced search api

Trying to fetch all tasks that are overdue at the current time. Most of our tasks use “due_on” but it would be nice to be able to find all overdue tasks with either “date” or “date-time” set. I am seeing these results:

Search param:
‘due_at.before’: new Date().toISOString() (i.e. current time)

Tasks with “due_at” before current timestamp are returned which is expected.
Tasks with “due_on” before current day are returned which is expected.
Tasks with “due_on” after current day are not returned which is expected.

However,
Tasks with “due_on” the same as current day are returned which is not expected.
So, if the “before” key is inclusive of date then I could switch to using yesterday as the value. However, then I would miss tasks due today at a specific earlier time.

Could someone confirm if the “before” keyword is inclusive of the date and how they might work around the issue I am running into?

Hi @Mitch_Montaldo,

Just wanted to confirm my understanding:

Scenario:

  • Task 1 → due_on = yesterday (04-19-2023)
  • Task 2 → due_on = today (04-20-2023)
  • Task 3 → due_on = tomorrow (04-21-2023)
  • Task 4 → due_at = yesterday (2023-04-19T19:00:00.000Z)
  • Task 5 → due_at = today (2023-04-20T19:00:00.000Z)
  • Task 6 → due_at = tomorrow (2023-04-21T19:00:00.000Z)
  • Task 7 → due_at = today (2023-04-20T08:00:00.000Z)

Send request to Search tasks in a workspace endpoint with the following query param:

due_at.before = 2023-04-20T19:00:00.000Z

EX: https://app.asana.com/api/1.0/workspaces/{workspace_gid}/tasks/search?due_at.before=2023-04-20T19:00:00.000Z

Expected Result:

  • Task 1 → due_on = yesterday (04-19-2023)
  • Task 4 → due_at = yesterday (2023-04-19T19:00:00.000Z)
    *Task 7 → due_at = today (2023-04-20T08:00:00.000Z)

Actual Result:

  • Task 1 → due_on = yesterday (04-19-2023)
  • Task 2 → due_on = today (04-20-2023)
  • Task 4 → due_at = yesterday (2023-04-19T19:00:00.000Z)
    *Task 7 → due_at = today (2023-04-20T08:00:00.000Z)

And you want to know a suggestion to get to the “Expected Result”? Is this the right understanding?

Yep! That is correct. Using a “due_at.before” for current time it will return tasks that are due_on the current day, which is not desired. Since tasks due_on today are not yet overdue.

Cool. Thank you for confirming @Mitch_Montaldo . Let me confirm with our API team on the behavior and suggestions and get back to you.

1 Like

Hi @Mitch_Montaldo,

Sorry for the long delay. Our engineer team got back to us and wanted to explain that “For tasks due on a date with no time-of-day specified, this timestamp is equal to midnight.”

So essentially, when you set a due date on a task without a time (i.e., due_on) we essentially treat it as a date time with the time of midnight. Using this knowledge you can craft your query in a way that can include or exclude the task(s) you want.

For example, let’s use PST time. Midnight would be T07:00:00.000Z (I got this by setting a task with a date + time of 12:00 am (PST) → and calling get a task and looking at the value for due_at)

So let’s say I have the following tasks:

Today’s Date = August 4th, 2023 (2023-08-04)

  • Task 1 → due_on = yesterday (2023-08-03) → Think of this as 2023-08-03T07:00:00.000Z
  • Task 2 → due_on = today (2023-08-04) → Think of this as 2023-08-04T07:00:00.000Z
  • Task 3 → due_on = tomorrow (2023-08-05) → Think of this as 2023-08-05T07:00:00.000Z
  • Task 4 → due_at = yesterday (2023-08-03T07:00:00.000Z) → yesterday at 12:00 am (PST)
  • Task 5 → due_at = today (2023-08-04T19:00:00.000Z) → today at 12:00 pm (PST)
  • Task 6 → due_at = tomorrow (2023-08-05T19:00:00.000Z) → tomorrow at 12:00 pm (PST)
  • Task 7 → due_at = today (2023-08-04T08:00:00.000Z) → today at 1:00 am (PST)

If I just want task 1 and 4 back and not task 2 as an example for my query I could specify: due_at.before=2023-08-04T00:00:00.000Z → Today at 5:00 pm (PST). Result =

  • Task 1 → due_on = yesterday (2023-08-03) → Think of this as 2023-08-03T07:00:00.000Z
  • Task 4 → due_at = yesterday (2023-08-03T07:00:00.000Z) → yesterday at 12:00 am (PST)
2 Likes