# Date/number ranges within search/filter

**URL:** <https://forum.obsidian.md/t/date-number-ranges-within-search-filter/8963>\
**Category:** Feature requests\
**Created:** [November 23, 2020, 3:01pm UTC](https://forum.obsidian.md/t/date-number-ranges-within-search-filter/8963 "2020-11-23T15:01:19Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![malecjan](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@malecjan](https://forum.obsidian.md/u/malecjan)\
**Post date:** [November 23, 2020, 3:01pm UTC](https://forum.obsidian.md/t/date-number-ranges-within-search-filter/8963/1 "2020-11-23T15:01:19Z")

</div>

### Use case or problem

- task-management integration in Obsidian using [Todo.Txt format](https://github.com/todotxt/todo.txt#additional-file-format-definitions)
- matching and filtering by properties: `price: (25 .. 30)USD`
- filtering stuff due for spaced-repetition
- [Expiration date or reminder for notes](https://forum.obsidian.md/t/expiration-date-or-reminder-for-notes/7814/5)
- [search notes by creation/modification date](https://forum.obsidian.md/t/additional-searching-metadata/8787)
- …

### Proposed solution

OPTION 1:  
Proposed syntax is combination of:

- [double dot](https://en.wikipedia.org/wiki/Ellipsis_%28computer_programming%29)  
“`..`” 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](https://courses.lumenlearning.com/ivytech-collegealgebra/chapter/using-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:

```auto
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

- producing search string listing each date belonging to range: [Search a range of dates with Keyboard Maestro on macOS](https://forum.obsidian.md/t/search-a-range-of-dates-with-keyboard-maestro-on-macos/3456)
  - -: Produced search string is excessively long and needs to be produced externally again each time we change the end date. Out of question for floating point numbers.

- complicated regular expressions
- existing implementation of number-ranges alone (not within phrase) in interval notation: [https://www.emeditor.com/text-editor-features/history/new-in-version-18-4/](https://www.emeditor.com/text-editor-features/history/new-in-version-18-4/)

### Related feature requests

- general:
  - [Improve date and time management](https://forum.obsidian.md/t/improve-date-and-time-management/8543)
  - [Filter notes, e.g. by date and has tags?](https://forum.obsidian.md/t/filter-notes-e-g-by-date-and-has-tags/964)

- task management in Obsidian:
  - [Making tasks/todos a first-class citizen](https://forum.obsidian.md/t/making-tasks-todos-a-first-class-citizen/466)
  - [Please support plain text files in txt and taskpaper format](https://forum.obsidian.md/t/please-support-plain-text-files-in-txt-and-taskpaper-format/4670/11)
  - [Todo's in Obsidian syncing with todo.txt file](https://forum.obsidian.md/t/todos-in-obsidian-syncing-with-todo-txt-file/2460)
  - [How do you handle tasks in Obsidian?](https://forum.obsidian.md/t/how-do-you-handle-tasks-in-obsidian/822/12)

- spaced repetition within Obsidian:
  - [Simple spaced repetition plugin](https://forum.obsidian.md/t/simple-spaced-repetition-plugin/343)

- time-based variables
  - [Natural Language Date Processing](https://forum.obsidian.md/t/natural-language-date-processing/1635)

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

---

<div class="post-metadata">

**Author:** ![malecjan](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@malecjan](https://forum.obsidian.md/u/malecjan)\
**Post date:** [January 2, 2021, 1:00am UTC](https://forum.obsidian.md/t/date-number-ranges-within-search-filter/8963/2 "2021-01-02T01:00:48Z")

</div>

use case:

> [@How do you manage News and History related topics?](https://forum.obsidian.md/t/how-do-you-manage-news-and-history-related-topics/2685/54):
>
> It would also be nice to work with dates in a comparative way, such as, “Who was/were the President(s) of Chad from 2001 - 2007?” but we don’t have any sort of numerical comparators.

---

<div class="post-metadata">

**Author:** ![malecjan](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@malecjan](https://forum.obsidian.md/u/malecjan)\
**Post date:** [January 2, 2021, 1:08am UTC](https://forum.obsidian.md/t/date-number-ranges-within-search-filter/8963/3 "2021-01-02T01:08:02Z")

</div>

Related feature request:

> [@Generalized front-matter metadata](https://forum.obsidian.md/t/generalized-front-matter-metadata/7375/1):
>
> Query notes according to their metadata, using some SQL-like language (example: select all notes where created is between X an Y and title begins with Z)

---

<div class="post-metadata">

**Author:** ![datum](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/d/e9a140/32.png) [@datum](https://forum.obsidian.md/u/datum)\
**Post date:** [January 2, 2021, 4:57am UTC](https://forum.obsidian.md/t/date-number-ranges-within-search-filter/8963/4 "2021-01-02T04:57:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![nicrivard](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/n/ecb155/32.png) [@nicrivard](https://forum.obsidian.md/u/nicrivard)\
**Post date:** [January 10, 2021, 11:08am UTC](https://forum.obsidian.md/t/date-number-ranges-within-search-filter/8963/5 "2021-01-10T11:08:28Z")

</div>

@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:

```auto
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:

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

```

---

<div class="post-metadata">

**Author:** ![datum](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/d/e9a140/32.png) [@datum](https://forum.obsidian.md/u/datum)\
**Post date:** [January 10, 2021, 2:24pm UTC](https://forum.obsidian.md/t/date-number-ranges-within-search-filter/8963/6 "2021-01-10T14:24:52Z")

</div>

@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](https://forum.obsidian.md/uploads/default/original/2X/8/844a175f8ef0a1f5dbf49c4277bf42c69adcd42f.png)

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.

---

<div class="post-metadata">

**Author:** ![nicrivard](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/n/ecb155/32.png) [@nicrivard](https://forum.obsidian.md/u/nicrivard)\
**Post date:** [January 10, 2021, 3:50pm UTC](https://forum.obsidian.md/t/date-number-ranges-within-search-filter/8963/7 "2021-01-10T15:50:34Z")

</div>

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:

```auto
'''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:

```auto
---
References: [[2021 W02]]

```

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

```auto
'''query
"References: [[2021 W02]]" line: ("- []" -"line:")
'''

```

---

<div class="post-metadata">

**Author:** ![maartin](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/m/b782af/32.png) [@maartin](https://forum.obsidian.md/u/maartin)\
**Post date:** [June 1, 2020, 3:30pm UTC](https://forum.obsidian.md/t/date-number-ranges-within-search-filter/8963/8 "2020-06-01T15:30:33Z")

</div>

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](https://forum.obsidian.md/uploads/default/original/1X/8504a7c60ae230f8bf2768491a44fe53e05577c3.jpeg)

**Filter query language**

- `has_tags:no AND created_at:<4weeks AND tag:prio1`

---

<div class="post-metadata">

**Author:** ![melch\_25](https://forum.obsidian.md/user_avatar/forum.obsidian.md/melch_25/32/9802_2.png) [@melch\_25](https://forum.obsidian.md/u/melch_25)\
**Post date:** [September 5, 2020, 8:51pm UTC](https://forum.obsidian.md/t/date-number-ranges-within-search-filter/8963/9 "2020-09-05T20:51:37Z")

</div>

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)
