Dataview query based on @YYYY-MM-DD date format

Things I have tried

I have a dataview query that I found on this forum (see below) that has been working well pulling any tasks I have where I used [[YYYY-MM-DD]] date format. I just realised there is an official way to set dates using @{YYYY-MM-DD} - I am now wondering the best way to amend this query to pull in tasks using the correct date format. When I use the below task the query works fine …

  • [ ] example task #todo [[2022-12-03]]

When I change the task to use the different date format it doesn’t work

  • [ ] example task #todo @{2022-12-03}

// find dates based on format @{YYYY-MM-DD}

const findDated = (task)=>{

if( !task.completed ) { = " " + "[[" + task.path + "|*]]";"";

const found = task.text.match(/\[\[([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))\]\]/);

if(found) = moment(found[1]);

return true;


const myTasks = dv.pages('""').file.tasks.where(t => findDated(t));


dv.taskList(myTasks.filter(t=> moment(,"day")).sort(t=>;


dv.taskList(myTasks.filter(t=> moment(,"day")).sort(t=>;


dv.taskList(myTasks.filter(t=> moment(,"day")).sort(t=>;

What I’m trying to do

I have tried amending the query pattern as below, but it just ignores my new tasks

// find dates based on format @{YYYY-MM-DD}

const found = task.text.match(/\[\[([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))\]\]/)

Do I need to change all [] for {} in the second line ? or is there a better way to do it? I am trying to figure out the regex pattern in this line

Official? by who? not by Obsidian (I think), but maybe by another plugin.
What’s the date means in your tasks? the due date?
It needs to be a link (for [[2022-12-03]] case)? What’s the output of @{YYYY-MM-DD}?
You use another plugin to tasks?

These questions aren’t directed to a concrete solution, but to avoid “customized” queries solutions.
Dataview works well with dates without the use of regex or similar… but for that you need to use some rules/syntax/fields.
If you’re not dependent on another plugin, my suggestion is: use regular dataview rules.

Apologies, I may have been confused. it looks like the @{YYYY-MM-DD} date format may be specific to the Kanban plugin I am now using for tasks not obsidian. I am using the date as a due date on my tasks.
The query I shared was use in my daily notes to pull in a list of overdue, due today and upcoming tasks based on their due date.

Looking only for the dataview plugin, if you write tasks in this format (three different ways in dataview)

-   [ ] example task #todo (due:: 2022-12-05)
-   [ ] example task2 📅 2022-12-07
-   [ ] example task3 [due:: 2022-12-03]

you can use this dataviewjs query

const myTasks = dv.pages('"dv.templates"').file.tasks.where(t => !t.completed)

dv.taskList(myTasks.where(t => t.due && t.due <'today')).sort(t => t.due, 'desc'), false);

dv.taskList(myTasks.where(t => t.due && t.due.ts =='today').ts).sort(t => t.due, 'desc'), false);

dv.taskList(myTasks.where(t => t.due && t.due >'today')).sort(t => t.due, 'asc'), false);

without the need of regex and with a best flexible compatibility with the plugin.

If you want to use the kanban format, well, try change the regex to

const found = task.text.match(/@{([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))}/);

(i’m not versed in regex, I just adjust the previous expression replacing the square brackets)

@mnvwvnm thats great, many thanks. I take your point about using the dataviewjs query to cover the three versions of dates. Works perfectly, Thanks

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