Tasks Due This Week #1652
Replies: 4 comments 6 replies
-
I was too hasty and didn't test into the future enough to realize this wouldn't work as is. I found that out today, the end of my week, which would mess up the results as initially written. I hadn't intended for this Show and Tell to be a 'watch the newbie learn from his mistakes', but there we are. I did finally figure out that I was using now.day when I should've been using now.startOf. I have to use the subtract and add because of how 'before' and 'after' function like > and <, there is no >= or <= operators in tasks as far as I can tell. Here's the updated code. I've tested by shifting the date on my computer into the future and the past, and it is correctly calculating start of week and end of week now. This still all gets wrapped in a dataviewjs codeblock, not a tasks codeblock, and the "explain" function in tasks is still one of my favorite things it.
|
Beta Was this translation helpful? Give feedback.
-
I'm a little confused by the latter part of the statement, i.e.
What do you mean by this? at any rate, another question I have is: where do you care to have this display of tasks? maybe in your daily note? |
Beta Was this translation helpful? Give feedback.
-
Hi @PeterBeckley, Thank you very much indeed for sharing your learnings. And I'm sorry it has been such a pain for you. It sounds like you have got something working now, which is great. But in case it helps, there was a previous discussion here: #1176 (comment) Also, in case you haven't seen it, the Finally, we have someone kindly actively developing queries like So it should get easier soon. |
Beta Was this translation helpful? Give feedback.
-
This is now possible via:
There are many more date-range search facilities - https://publish.obsidian.md/tasks/Queries/Filters#Searching%20date%20ranges I'll close this as released. |
Beta Was this translation helpful? Give feedback.
-
My goal is to dynamically display all tasks in my vault, for the current week only, which have the global filter but are not part of any templates I've made. Right now, I can't find a way to do this with a tasks code block because "this week" and "next week" aren't ranges. However, using a dataviewjs codeblock it can be done. It's still a little weird because there isn't something like >= a day, just > a day for "after", as far as I can tell by using the "explain" option in the tasks code block (which is a fantastic tool, by the way!)
As you can see I get the current date from the computer (now), then use moment, included with Obsidian, to then get the first and last day of the current week. My weeks go from Monday to Sunday, so you may have to play with the sow and eow numbers to make it work for you initially.
My query is pretty basic. "not done" means all uncompleted tasks. the "NOT (path)" makes sure none of my template files will be included. Some of my templates combine templater and task code blocks to made clever notes. The due after and due before are the parts I couldn't get to work with just a tasks code block. "hide task count" is obvious. The dv.paragraph takes everything from the top part and puts it into a tasks code block, which is just the coolest thing to me.
I'm not a developer, it took me far too long to read through all the pages of examples and documentation for tasks and dataview before finally figuring out this solution. I don't know if I'll be able to trouble-shoot any issues you may have if you choose to use this code. I just figured I'd share it since it solves a problem I ran into. Remember, you have to wrap what you copy from here in a dataviewjs block not a tasks block.
Beta Was this translation helpful? Give feedback.
All reactions