I want to query for all uncompleted tasks containing a tag and a date (as tag), which is in the next x days. To e.g. get an overview over all upcoming tasks for the next 7 days containing a specific tag. Since I’m pretty new to Obsidian and completely new to dataviewjs I am honestly lost. Above is my working approach without the date filtering.
An example line that should be caught as of today would be
Thanks so far. Regex is no problem at all, I think
[\d]{4}-[\d]{2}-[\d]{2}
should do the job for me. The question for me would then be how to connect everything. So how to include the regex and compare the result as date object to the current date.
For me dates in JS are a mistery… So, now it’s your time to find a way to delimit the next x days from today date
EDIT:
This is a ‘stupid’ repetition, but maybe with dv.date(t.text.match(regex)[0]) > dv.date('today') && dv.date(t.text.match(regex)[0]) <= dv.date('today').plus({days: 7})
Thanks a lot so far. The date stuff should be fine, however I’m a bit stuck with the regex match command. Obviously t.text.match(regex)[0] should match the first group, but it seems that sometimes no group is returned (probably when nothing is found in a task), causing the evaluation to fail
Evaluation Error: TypeError: Cannot read properties of null (reading '0')
at eval (eval at <anonymous> (plugin:dataview), <anonymous>:4:117)
at Array.filter (<anonymous>)
at Proxy.where (plugin:dataview:9414:39)
at eval (eval at <anonymous> (plugin:dataview), <anonymous>:4:79)
at DataviewInlineApi.eval (plugin:dataview:19673:16)
at evalInContext (plugin:dataview:19674:7)
at asyncEvalInContext (plugin:dataview:19684:32)
at DataviewJSRenderer.render (plugin:dataview:19705:19)
at DataviewJSRenderer.onload (plugin:dataview:19289:14)
at DataviewJSRenderer.e.load (app://obsidian.md/app.js:1:852364)
So I tried getting rid of this case, but that approach always returns an empty result list:
btw what is the best way to debug print variables within dataviewjs? I just learned the hard way that document.write is a pretty bad idea and that window.alert is not much better.
(the other things you wrote are unknown to me - I’m not a coder, programmer or similar )
About your previous post with the code, well I really don’t know how function works but I guess - just a guess, because the syntax - if you use m = t.text.match(regex), then you need to use something like:
function safe_match(t) {
m = t.text.match(regex)
if (m != null) {
return m[0]
}
}