Adding flag to overdue tasks?

I am trying to visually mark a task as overdue in DataviewJS. My code adds a ‘red flag’ for tasks that are overdue, but I can’t complete these tasks. I assume because the text of the task doesn’t match the actual tasks.

Any ideas on how to do mark tasks as overdue other than creating a separate dataview section with only overdue tasks?

Thank you!


```dataviewjs

let pages = dv.pages().file.tasks

for (let i = 0; i < pages.length; i++) {
 if (moment(pages[i].datum, "DD-MM-YYYY").isBefore(moment(), "day")) {
pages[i].text = "🚩 " + pages[i].text
}
} 
dv.taskList(pages)

My suggestion (in DQL, because JS isn’t my ground) is to group the tasks (overdue vs in time). For example (considering due as an inline field in task text):

TASK
FROM ""
WHERE !completed AND due
GROUP BY choice(due < date(today), "🚩 overdue", "🟢 in time") AS abc
1 Like

Thanks!

I believe this method would not individually highlight tasks with a flag? That is actually what I was looking for.

Hi. That’s why I started my post with “suggestion”, not “solution” (because sometimes we don’t have “solutions”, only “alternatives”).

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.