One thing is the format you use as date value, ie, the value in your field. About this, you need to use a format recognized by dataview. Dataview uses the format ISO8601, ie, YYYY-MM-DD.... Data Annotation - Dataview So, the point is: to be a format recognized by dataview you need to use this form.
Other thing is the format you want to see in the output results. If you want to see dd-MM-yyyy then you need to ‘convert’ the original format to the wanted output. For example, if in date date: 2022-05-03 and you want to see in the output 03-05-2022, then you use the function dateformat() in this way: dateformat(date, "dd-MM-yyyy")
using the luton format tokens - luxon/formatting.md at master · moment/luxon · GitHub
As said before, one thing is the right format to be recognized as date, other thing is the output format.
The recognized format has the form YYYY-MM[-DDTHH:mm:ss.nnn+ZZ] (as mentioned in documentation, “everything after the month is optional”.)
In your example, 2022-05-03-Tuesday is recognized as a simple string, not a date. Usually the default output of a date (defined in Settings > Dataview) take the form of MMMM dd, yyyy, something like May 3, 2002 (you can test the output with the inline query =date(today)).
There’s only one implicit field that accept other words and extract only the date - the field file.day (for titles > you can use [[2022-05-03 My daily note]] and file.day extract only the date).
To work normally, your field need to be like this: DateWatched:: 2022-05-03.
But you can work with that value in a no-normal way, using some regex to extract everything from the last “-”, i.e., removing “-Tuesday” (with the function regexreplace()) and then use the function date() to transform the string 2022-05-03 in a recognized date).
I’m a dumb in regex (not only), but you can try something like this:
Everything makes total sense now that you have explained it to me. As ever, I am very grateful. I will try with regex or perhaps just use VS Code to remove the days of the week from the strings so that they then work in line with the documentation.
I use a lot simple inline queries to check the right format of the fields in the current note. Something like =this.field…
And to check all metadata in current note in structured way I use this one (inline js query):
Indeed I had changed the default format. I like to see the day of the week and I had understood that everything after the month was optional. I had also assumed that that meant that anything after the month was also permissible, but I clearly misunderstood.
Despite lots of attempts, I can’t figure out where to place the regex in the query, and even though I tried to edit the dates to yyyy-MM-dd format in the inline fields, I can’t then get Dataview to display those dates in Day-dd-MM-yyyy or even dd-MM-yyyy format in the table.
So I have decided to find a book to read and to come back to this tomorrow.
I can read the dates as they are (backwards to my brain). It would just be nice to be able to read them more naturally. Think it is easier to stick with the simple system I have now and continue to enjoy things rather than get frustrated.
I’m not sure about your desired output (and please correct my regex if wrong - I copied and edit it from other code… I really don’t know what means each code character ):
TABLE WITHOUT ID
file.link AS Film,
date(regexreplace(DateWatched, "-[^-]*$", "")) AS Test,
dateformat(date(regexreplace(DateWatched, "-[^-]*$", "")), "dd-MM-yyyy") as When,
dateformat(date(regexreplace(DateWatched, "-[^-]*$", "")), "dd-MM-yyyy-cccc") as When2
WHERE DateWatched