Dataview, Not working: TABLE WITHOUT ID link(file.link, Date) AS "Date"

Things I have tried

various code, researching

What I’m trying to do

TABLE WITHOUT ID link(file.link, Date) AS "Date", Summary, Note
FROM "" AND !"900 Templates"
Where Author = "John Doe"
SORT Date ASC

The above doesn’t seem to work for me. It returns only 2 results. Results that do not even have the Date in YAML.

However if I add, Date to the columns, e.g.

TABLE WITHOUT ID link(file.link, Date) AS "Date", Date, Summary, Note
FROM "" AND !"900 Templates"
Where Author = "John Doe"
SORT Date ASC

I do get all my notes, but now I have two date columns. Also, the first date column are not links like I want it. Instead of the file name, I want to be able to click on the date.

Not sure why I’m getting this behavior in both cases.

Best,

R

You need to add more information:

  • What’s the format of your value in Date field? YYYY-MM-DD?
  • What’s your desired date format output? yyyy-MM-dd?
    The question is: we can’t use directly Date as the second argument in link(A1, A2) - because a date. It’s necessary to “transform” this value in a string or similar. For example:
link(file.link, string(Date))

or, to control the output format

link(file.link, dateformat(Date, "yyyy-MM-dd"))

hmm. I may have bit off more than I can chew. :slight_smile:
Yes, the date field is YYYY-MM-DD and my desired output is the same, but not sure what the difference is w/ the capital and non-capital versions.

I tried what you posted. E.g.

TABLE link(file.link, dateformat(Date, "yyyy-MM-dd")), Summary, Note
FROM "" AND !"900 Templates"
Where Author = "John Doe"
SORT Date DESC

but I get an error

Dataview: Error:
– PARSING FAILED --------------------------------------------------

1 | TABLE link(file.link, dateformat(Date, “yyyy-MM-dd”)), Summary, Note
| ^
2 | FROM “” AND !“900 Templates”
3 | Where Author = “John Doe”

Expected one of the following:

‘(’, ‘*’ or ‘/’, ‘+’ or ‘-’, ‘.’, ‘>=’ or ‘<=’ or ‘!=’ or ‘=’ or ‘>’ or ‘<’, ‘[’, ‘and’ or ‘or’, whitespace

thanks so much!

You need to complete the expression with the wanted column name:

link(file.link, dateformat(Date, "yyyy-MM-dd")) AS "Date"

Aha, but now I get both the file name and the date… I do not want the file name column however.

also what’s the difference between YYY-MM-DD & yyy-MM-dd?

related with the output date format, see Luxon tokens:

1 Like

cool, thx. how do I remove the file name column?

use TABLE WITHOUT ID

see my previous post to output format. about the input format - “YYYY-MM-DD” -, this is a generic way to refer to “2022-04-08”. But for output format the tokens are important

1 Like

YES! got it. thanks so much and have a great weekend.

Thanks for experiencing my issue before me, @romebot :pray:

FWIW @mnvwvnm - I came up with this issue not related to Dates & believe @romebot & my examples combined might suggest a Dataview bug. Will you kindly review?

To replicate (on v0.4.26):

  1. Setup
    • Create file result 000000001.md with inline data
      parents:: [[mission 000000003]]
      class:: [[RESULTs]]
      title:: "my lovely title"
      
    • Create file RESULTs.md to aggregate sub-files via DataView Table.
  2. In RESULTS.md try various DataView combos using link()
    • :ok_hand: default
      TABLE parents.title, title
      FROM ""
      WHERE  contains(class,this.file.link)
      SORT parents.title, title
      
      image
    • :ok_hand: Verify link() works with LIST
      LIST WITHOUT ID link(file.name, title)
      FROM ""
      WHERE  contains(class,this.file.link)
      SORT file.name DESC
      
      image
    • :interrobang: Expect list() to work with TABLE
      TABLE WITHOUT ID link(file.name, title), parents.id
      FROM ""
      WHERE  contains(class,this.file.link)
      SORT file.name DESC
      
      image
    • :ok_hand::interrobang: Add in AS (as described in Description)
      TABLE WITHOUT ID link(file.name, title) as OBS_FORUM_TEST, parents.title
      FROM ""
      WHERE  contains(class,this.file.link)
      SORT file.name DESC
      
      image
  • :thinking: I am not expecting to need AS since not written in documentation.

Hi.
What you describe isn’t a bug. In tables (not in lists) if you use only fields in the first line they’re used as the column names (parent or parent.title…). But if you use anything else - e.g. a function as link() - you need to add a new name to the column. That’s why you need to use AS.
But it’s not worth it explain more because the behavior will change in the next public releases. As you can see here - Release 0.5.3 · blacksmithgu/obsidian-dataview · GitHub - this will become optional.