Dataview show all files from same day based on metafield

What I’m trying to do

In all my notes i use a inline metafield called “datecreated”. Every time i create a note templater insert automatically the date in the format yyyy-mm-dd.

For example:
datecreated:: 2022-08-05

The reason i use datecreated is that i sometimes miss creating a daily note and then i need to recreated on another day. For example, I forgot to create on monday the 1st of august and create the file a the 4th of august. Then is the file.cday 2022-08-04 and i will write 2022-08-01 in the metafield “datecreated”.

Now i want to list all the files which were created at the same day as the shown “datecreated”. I refer to file.cday.

So my dataview block looks like this:

TABLE  file.cday
WHERE date(datecreated) = file.cday
SORT file.cday DESC

But the result is not what i want. See the image. In this example, the metafield is datecreated:: 2022-08-05.

Dataview also shows file where the file.cday’s are not matching. I dont know why. Maybe someone knows what to do :slight_smile:

And if i dint make clear what i need than please let me know.

Thank you

I am not completely sure I am understanding the question. I am assuming you want a query that will return all notes that either were created on 2022-08-05 or have the following field and value:

datecreated:: 2022-08-05

I am not sure this is the best way to do this, but it works. Anyways, here’s the query:

TABLE file.cday
WHERE contains(datecreated, date(2022-08-05)) OR file.cday = date(2022-08-05)
SORT file.cday DESC

Hopefully this helps. Good luck!

If you want to compare to the “datecreated” of the file where you are querying from, use this.datecreated in your WHERE. Otherwise the WHERE will compare the file’s own “datecreated” to its file.cday, not the “datecreated” from the page you are querying from!

Thank you so much. That “this.” was exactly what i was looking for :slight_smile:

1 Like