How to query for month overview? #1185
-
So I hope I didn't overlook the answer to this question, but I tried to figure it out myself and I couldn't make it work, so maybe somebody can help me out. I've been playing around with the tasks plugin and I wanted to create a special view as a weekly and a monthly overview. Basically I want to query the tasks so that they show me all tasks of the current week / all tasks of the current month. For the week I managed to create the view thanks to the answers in that discussion: Now I've been trying to implement a similar view for the current month but whatever I tried, the query result is either no tasks or it includes tasks from the next month (seems like it just takes the tasks from the next 30 days or something). Is there a way to just query for the current month without setting specific dates? I would love to not set specific dates because that would make maintaining that view quite annoying... Thank you for all the work you are putting into that plugin! |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 6 replies
-
I fear this is not possible (tested with chrono 2.4.1). While We should do some research whether there is a better library, or maybe build one just for Tasks (that would only understand English, to narrow the scope). |
Beta Was this translation helpful? Give feedback.
-
Anything that I can't do in tasks, I crack open dataview to use it to do the calculations I want, and write out my tasks block. There is one example of this in the Tasks docs, as a starting point. If you know any JavaScript, you could get the start and end dates of the current month, and then write out a tasks block that uses those dates. It's a bit of a sledge hammer to crack a nutshell, but it's what we've got at the moment... |
Beta Was this translation helpful? Give feedback.
-
I've been toying with the idea of providing a new date-range search feature, to make these kinds of common questions easy to answer. This would be relatively straightforward, and whose code would be clearly separate from chrono, but whose implementation could use it. Here's the idea - based on
And a user preference to say whether their week starts on Sunday or Monday - since chrono starts weeks on Sundays which is useless to me. Although that might confuse people if we cannot make their chrono-based filters use the same information. |
Beta Was this translation helpful? Give feedback.
-
Thank you so much for your answers, I am only getting back to this question now because life got busy the past few days. @claremacrae The new date-range search feature sounds amazing, it would definitely help me a lot if that ever gets implemented. I too need a week starting on Monday, though I wonder if there might be use cases for other days as start of the week, too? I am definitely going to check out the link you posted and see if I can make it work with Dataview/Javascript for now. Thank you again! |
Beta Was this translation helpful? Give feedback.
-
I managed to make it work with DavaviewJS and I wanted to share it with anyone who might be struggling with the same problem. ```dataviewjs
const currentDate = new Date();
const currentMonth = currentDate.getMonth();
const currentYear = currentDate.getFullYear();
const lastDayOfLastMonth = new Date(currentYear, currentMonth, 0);
const firstDayOfNextMonth = new Date(currentYear, currentMonth + 1, 1);
const query = `
not done
due after ${lastDayOfLastMonth}
due before ${firstDayOfNextMonth}
# You can add more task instruction here like:
hide due date
`;
dv.paragraph('```tasks\n' + query + '\n```'); Don't forget the three ``` at the end, I am struggling with the code-block formatting here... |
Beta Was this translation helpful? Give feedback.
-
There are now specific searches in Tasks, such as See the docs: |
Beta Was this translation helpful? Give feedback.
I managed to make it work with DavaviewJS and I wanted to share it with anyone who might be struggling with the same problem.
Code is not tested extensively but should work. Feel free to correct me if I am wrong.
Do…