Obsidian Tracker Plugin - Need help to accept any dateFormatPrefix and dateFormatSuffix as long as the file has date format YYYY-MM-DD

Hi,
I’m trying to get the the Obsidian Tracker Plugin to consider all files whose names contain a date formatted as YYY-MM-DD, regardless of what is the prefix or the suffix around that date.

I’ve checked the documentation and got it partially working using the dateFormatPrefix, dateFormatSuffix input parameters, but still with inconsistent results.

Sometimes I get the error:
image

Or, depending on what searchTarget i’m using, I get a few pages tracked, when I’d expect lots of pages.
image

Below is an example of what note file names look like.

2022-07-28 Thu - Wake up
2022-07-28 Thu
Meeting Note 2022-07-28 - Delta HFC

Things I have tried

Here’s how I attempted to ignore anything before or after the date format YYY-MM-DD.

searchType: tag
searchTarget: tag1
folder: 
dateFormat: YYYY-MM-DD
dateFormatPrefix: '.* '
dateFormatSuffix: ' .*'
startDate: 2022-07-01
endDate: 2022-07-30
line:
	title: Tag #tag1
	yAxisLabel: Count
	lineColor: "#d65d0e"

I tried many other variations, such as excluding the spaces, and also:

dateFormatPrefix: '.* '
dateFormatSuffix: ' .*'

dateFormatPrefix: '(.* |.*)'
dateFormatSuffix: '( .*|.*)'

dateFormatPrefix: '.*(?=(\d{4}-\d{2}-\d{2}))'
dateFormatSuffix: '(?<=(\d{4}-\d{2}-\d{2})).*'

I’m not very familiar with regular expression. Any help to figure this out will be much appreciated.

Thanks :+1:
Renato

What I’m trying to do

That sounds frustrating! I have a bunch of filenames that start with the date and then have arbitrary amounts of text afterwards (calendar events). " .*" without the backticks is what I have in my dateFormatSuffix. So I do not know why yours is not working. Maybe try putting a few files in a test folder, use the folder: field to specify the test folder, and see if you can figure out what works and what does not?
Good luck!

1 Like

Thanks @scholarInTraining,

I finally got it :raised_hands:

The problem was the dateFormatSuffix.
I finally came out with a regex that satisfies my use cases, which I’ll detail below for anyone who’s in the same situation and needs two regex that work for them.

My date format is YYYY-MM-DD globally.
My Daily notes have a ddd suffix, so YYYY-MM-DD
As I indicated before, a date can be anywhere in the file name.
And a date in the file name is always surrounded by space.

``` tracker
searchType: dvField
searchTarget: Efficiency
folder: 
dateFormatPrefix: '.*(?=(\d{4}-\d{2}-\d{2}))'
dateFormatSuffix: ' .*'
startDate: 2022-07-01
line:
	title: dvField - Efficiency
	yAxisLabel: Count
	lineColor: "#d65d0e"

That resolves the dateFormatPrefix (in blue below)
image

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.