DataView and Linter - Help with dates

What I’m trying to do

This is my current set-up:

  • I am using the Linter plugin to automatically attach creating and last modified dates to my notes. I found this can be really important during lectures i my Uni, as I can quickly access the files I recently edited on connected topics - This works as expected.
  • I then have a note block in my main JSON canvas, with a dataview, not dataviewjs query, that puts these last edited files into a table in order of last edited - This is where my issue is.

The query in question is this one below:

TABLE date(file.frontmatter.date_modified, "MM.dd.yyyy HH:mm:ss") AS "Last Changed" SORT date(file.frontmatter.date_modified, "MM.dd.yyyy HH:mm:ss") DESC LIMIT 15

Now generally this works. However, it seems as it’s not consistent with formating the minutes of the queries correctly, or more precisely it always displays the minutes as :04 no matter what the note contents actually are.

For example, if the in-file frontmatter is:

date_modified: 04.04.2024 14:20:22

Then the entry in the dataview table will display:

2024-04-04, 14:04

In some cases this seems to cause incorrect ordering of files edited in the last hour, or at most it works, but it isn’t consistent.

Things I have tried

Im not sure if this is some inconsistency between the moment.js date format that Linter uses and the luxon format that dataview uses.

However, I have tired trying different configurations, of padded and unpadded values, different date values or formats in general, and all of them produce the same output.

My current Linter date format is the following:


I have also tried to pass different formats into the date() function of dataview, these either resulted in the same output, of the inability to parse the date. Sorting by the text value of the frontmatter property also doesn’t seem to produce the correct ordering.

I’ve also tried changing the property type to date & time, but that seems to encounter issues with the Linter plugin, as it doesn’t actually set the property correctly.

Does anyone have any ideas on how to make this work properly? Is there something I missed in the DataView or Linter documentation, I think I went through them well enough.

Any help would be appreciated. Thank you all in advance!

I would try a different format that may work better with dataview.

I have: YYYY-MM-DDTHH:mm, where there is a T prefix for the hours and minutes. You can use the US way of dates still.

There was a thread or two in the last few weeks and I seem to remember a space being the problem. Add the T for time and see if it fixes problems.

Thank you for the reply… I appologize for not seeing the old posts. I had to somehow miss them.

I did end up trying that, and it did make the Linter YAML timestamp frontmatter compatible with the date & time data type, which is neat. However, it didn’t seem to fix my issue.

Dataview still is rendering and sorting the parsed dates with the value of :04 in the minutes location instead of the actual value of the minutes.

I did try extracting the seperate parts of the date value (hours, minutes, etc.) and the values seem to be correct there, so for now, I ended up putting together the abomination below which seems to work… Maybe if anyone has some other solution I would love to see it.

date(file.frontmatter.date_modified).year + "-" + date(file.frontmatter.date_modified).month + "-" + date(file.frontmatter.date_modified).day + " " + date(file.frontmatter.date_modified).hour + ":" + date(file.frontmatter.date_modified).minute as "Last Changed" 
SORT date(file.frontmatter.date_modified).year DESC, date(file.frontmatter.date_modified).month DESC, date(file.frontmatter.date_modified).day DESC, date(file.frontmatter.date_modified).hour DESC, date(file.frontmatter.date_modified).minute DESC LIMIT 15

P.S.: I did also try using the file.mtime attribute. I don’t like it since I only want the directly changed files listed, some files are changed via scripts and Lintr isb’t triggered then, but file.mtime still updates which I don’t want. And this produced the same behaviour of listing :04 for the minutes section.