Dataview Date Formatting

What I’m trying to do

I have a dataview as follows:

	FROM #InventoryItem
	WHERE = "Air Pump"
	SORT asc

The file Air Pump looks like this:

dateOfPurchase:: 2021-09-10

So far, so good. However, when the dataview is rendered, it changes the date format to “September 10, 2021”. This makes the date too long, and breaks each row into multiple lines.

I’ve attempted to use several formatting ways, such as:

  • dateFormat(dateOfPurchase, “YYYY-MM-dd”)
  • date(, “YYYY-MM-dd”)
  • date(dateOfPurchase, “YYYY-MM-dd”)
  • Etc.

I’ve scoured the Dataview documentation, searched these forums, and googled this.

However, no matter what I’ve tried, the date always displays as “September 10, 2021”.

Is there any way to apply a date format to a date shown in a dataview? I’m trying to get it to display as either of:

  • 2021-Sep-10
  • 2021-09-10
1 Like


You have to options:

1 - if you want to apply a specific format to all your date outputs, go to settings > dataview and change the output date format using luxon tokens.

2 - if you want to change a specific output in the query, use the function dateformat(field, "yyyy-MM-dd") and use the luxon tokens.

For example, for the format “2021-09-10” use

dateformat(dateofpurchase, "yyyy-MM-dd")

… for “2021-Sep-10” use:

dateformat(dateofpurchase, "yyyy-LLL-dd")

Luxon tokens: luxon/ at master · moment/luxon · GitHub


Thanks! While option #2 continues to not work for me, option #1 did the trick.

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