Date/number ranges within search/filter

Use case or problem

Proposed solution

OPTION 1:
Proposed syntax is combination of:

  • double dot
    ..” is used to denote range in some programming languages and does not play any other common role, except parent directory in file path.
  • interval notation
    Allows concise inclusion/exclusion of bounding values and AFAIK, every student learns it in school.
  • Interval notation alone without double dot would be easily confused with other meanings (markdown links, ordinary parenthesis, yaml lists, …).
  • Proposed syntax (see examples) is distinct enough to avoid need for escaping in most cases. When search for unusual literal string like due:(a .. b] is needed anyway, then use regular expression /due:\(a \.\. b \]/.

OPTION 2:
Double dot can be replaced by another keyword, e.g. (a TO b).

OPTION 3:
Alternative using just one type of brackets:

  • Include both starting/ending values in range: (a .. b)
  • Precede starting/ending value by “-” to exclude it from the range.
    (-a .. b), (a .. -b), (-a .. -b)
    This is consistent with current exclusion syntax in search.
  • To express negative numbers, enclose them in parentheses:
    • ( (-5) .. 5 ) = range from minus five to plus five including both ends
    • ( -(-5) .. -(5) ) = range from minus five to plus five excluding both ends

Examples

  • [2020-11-23 .. 2020-12-23] includes all dates between 2020-11-23 (including) and 2020-12-23 (including)

  • (2020-11-23 .. 2020-12-23] as above but 2020-11-23 is excluded

  • (2020-11-23 .. ) or (2020-11-23 .. ] includes all dates after 2020-11-23 (excluding)

  • [2020-01-01 .. yesterday], [today .. today+7days] common time-describing words could be recognized in ranges or maybe they could be specified using some format for variables, e.g. {{yesterday}} or !yesterday (reminds of transclusion syntax).

  • [2020-11-23 .. 2030) when at least one bounding value is in format YYYY-MM-DD, then the other value is treated as date also.

  • [-55.5 .. 66] number range, including negative and non-integer values. In settings would have list of characters that match as decimal separator, e.g. “.,”.

  • (20201123 .. 20211123] Number range allows also to search dates in concise format.

  • [0.5 .. 0.9.18.1b] When at least one bounding values contains more than one dot, then dot-separated sequences are considered. Use case: Matching versions.

  • due:(2020-11-23 .. 2021-11-23] range syntax can be recognized within phrases.

  • possible extension to other value types, e.g. strings ["string1" .. "string2") to get “index” or “dictionary”.

  • Syntax for range should work together with specification of path in nested yaml metadata.
    E.g. something like SRS/past-repetitions/[2020-09-01 .. 2020-12-01) would match in YAML:

SRS: 
	next-repetition: 2021-12-23
	past-repetitions: 
		- 2020-01-01
		- 2020-10-10
  • Why Date/time in ISO 8601 format? Because it is language independent and elements are ordered by time-scale: millennia→centuries→decades→years→months→days→hours→…

Current workarounds

Related feature requests

keywords: after, before, begin, bounded, deadline, duration, end, future, greater than, infinity, less than, limit, past, period, range, scope, sequence, span, start, stop, time

19 Likes

use case:

1 Like

Related feature request:

Ranges are nice, but I’d also be happy if we could just do basic comparisons in search based on collating sequence. If, today, I wanted to see all of my notes for the past week (assuming zettelkasten dates), it could look like this:

file:/^202(012(2[6-9]|3[01]))|(10101)/

Ugh. Translation: any note that is dated 20201226 through 20210101. This would be cleaner:

file:/^.{8}/ >= 20201226

Translation: Any note dated on or after 20201226

Even more cool if we could exploit regex back-reference value. For example, looking for a key value:

/^weight: ([0-9]+)/ > 50

Translation: key “weight” must have a value greater than 50.
Although I admit that this format could run into ambiguity if one’s regex has a necessary parenthetical expression, such that more than one back-reference value is interpreted. Then we’d need a way to specify which one, which could get messy.

@datum I’m trying to do something similar to search for incomplete tasks due this week.

For context, I mark tasks as “- [ ] DUE: YYMMDD dddd” and the date format in my daily notes template is also “YYMMDD dddd”

So, this week’s search query looks something like:

line: (“- [ ]” 2101/[0-1][0-9]/)

However, I can’t figure out how to get this in a template®. I’m stuck on something like this:

line: (“- [ ]” /{{date:W|[2-9][0-9][0-1][0-9][0-3][0-9]}}/)

@nicrivard, when you talk about putting it in a template, I’m not sure what you’re trying to do. I don’t use daily notes, or templates (yet), but my understanding is that your use of {{ }} with date is for displaying the current date/time. Based on this, and a cursory inspection of the detailed date formatting documentation, that last line, in a template, should render a line that looks something like this:

(“- ” /W|2-90-90-10-90-30-9/)

I’m not sure of your requirement. If the goal is to just put a search query into the note derived from a template, such that the line represents the necessary query to find certain note(s), then it’s just a matter of formatting. If the goal is to actually have a list of incomplete tasks automatically populated by the template, you’d have to use a search block in the template:

```query
/^- {{date}}/
```

where {{date}} can be whatever format you want. This search would not appear in the template preview, because {{date}} isn’t expanded; only in a note derived from the template. This would give you a list of notes and matching text (tasks) embedded in the note derived from the template. I don’t particularly care for how embedded searches are implemented because you can’t see the note as a hover action, as you could with a link, and you can’t copy the list out, as you could with the search plugin. Although you can jump to those notes, as you can with a search result.

I’m currently working on a dashboard as an external script. I’ve seen someone post an external script for displaying daily notes on a calendar, but I find that too restrictive (I don’t use daily notes). So far I have a dashboard that, given a set of notes (literally the search results list from Obsidian, which you can copy/paste) it will provide certain information. This means I can use any search capability internal to Obsidian or external from the system, to generate a note dataset. The script will provide a dashboard note of those notes on a calendar, like this:
Screen Shot 2021-01-10 at 9.03.37 AM

so you can see # of notes per day, which is a link to a timeline of those same notes, as well as a frequency distribution of number of notes per month. I’m not sure how this works on Windows, but on Linux/Mac, Obsidian automatically re-reads the note when it’s updated, so I can schedule automated dashboard updates from the system, and Obsidian will always display the latest dashboard(s).

Why am I telling you this? Because having completed the calendar, timeline, and frequency distribution, I was thinking about also adding To-do-type entries extracted from the given note dataset. I intend to post it to Share & Showcase, which presents a problem: people have different ways of indicating to-do’s. I’d have to somehow make it configurable, which is going to take longer. I’d also like to include some automatic key/value analysis from the dataset, but I’m not sure how that will look yet, although as a feature, that syntax is fairly strict: on a separate line, key-name followed by colon and space. So I may start with that first because it’s sraightforward. But I really would like to capture to-do items because I want to be able to sprinkle them in any note I happen to be working on, and find them all in a single place on the dashboard. If your idea is to get the incomplete tasks into every daily note, that’s a great concept for daily-noters.

1 Like

Wow! Thank you @datum for the detailed response.

I’ve been experimenting since my post and I think I’ve found an acceptable workaround by renaming my week notes to “YYYY Www” e.g. 2021 W02.

My requirement was two-fold:

  1. Ability to view incomplete tasks for any given day
  2. Ability to view incomplete tasks for any given week

For requirement #1, this was more straightforward. I was able to embed a search query in my daily note, for example:

'''query
line: ("- [ ]" 210104 -"line:")
'''

For requirement #2, the workaround I’ve identified involves referencing the week note in each daily note, for example at the bottom of my daily note:

---
References: [[2021 W02]]

and then on my week note I have this embedded search query:

'''query
"References: [[2021 W02]]" line: ("- [ ]" -"line:")
'''
1 Like

To quickly find and work on relevant notes, a filter bar or filter query language would be helpful.

Criteria to filter by:

  • Last viewed date
  • Last edited date
  • Creation date
  • Has Tags?
  • Customizable filter, e.g. by priority (#prio1, #prio2, #prio3)

Filter bar
(Inspiration from Receipts App)
Image 2020-06-01 17-25-52

Filter query language

  • has_tags:no AND created_at:<4weeks AND tag:prio1
15 Likes

I miss a strong filtering plug in where you can change the names and reorder the filters, the actual solution (starring searches is a bit poor)