Query Based on Month

New Silverbullet user here, I’m quickly falling in love with this tool.

I use monthly checklists in order to keep track of items I have to do regularly throughout the year. I can implement these as tasks within a file easily enough.

On my index page, I thought it would be great to have a live query of the tasks for the current month. I was hoping to use the ‘Today’ function and pull out the number of the month, and then either transform that to a month-name and match off a month-name tag, or just tag the various tasks with the month number and use that without any transformation.

Does that look like it could be possible, and what would the query look like? I’m not a huge SQL / developer type, so I’ll be excited if I can learn something new.


1 Like

i have the same question.

Someone previously posted a few additional date functions, including one that returns the current month:

silverbullet.registerFunction({name: "monthNumber"}, () => {
  return Temporal.Now.plainDateISO().month;

If you go ahead and add a month attribute to your tasks (e.g., [ ] Something to do [month:6], you could render tasks where that month attribute matches the current month:

{{{task where month = monthNumber render [[Library/Core/Query/Task]]}}}

I prefer to see tasks in the next 30 days though, so I’m comparing addDays(today, 30) with the deadline attribute in the following template:

{{{task where !done and deadline <= addDays(today, 30) order by deadline render [[Library/Core/Query/Task]]}}}