I have JSON formatted a column with the following:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "a", "txtContent": "*****", "attributes": { "target": "_blank", "href": "='https://*****.sharepoint.com/sites/group-*****/Lists/*****%20*****/AllItems.aspx?FilterField1=Person&FilterValue1=' + [$Author.title] + '&FilterField2=My_x0020_DateColumn&FilterValue2=' + toLocaleDateString([$Start])" } } It outputs a link to another list that is filtered on a Person and Date column.
The link creation works correctly, however the date from toLocaleDateString() is output as:
21/12/2020 whereas it needs to be:
2020-12-21 or perhaps even:
2020-12-21&FilterDisplay2=21%2F12%2F2020 for the filter to be applied correctly (even though the value in the column is actually displayed as 21/12/20).
How can I output the date value as YYYY-MM-DD so that the filter is applied correctly?
Edit
Have implemented @Jerry_MSFT 's solution as follows - for some reason it is returning month as 11 rather than 12 (does getMonth() return a 0 indexed value? or is something weird happening?):
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "a", "txtContent": "*****", "attributes": { "target": "_blank", "href": "='https://*****.sharepoint.com/sites/group-*****/Lists/*****%20*****/AllItems.aspx?FilterField1=Person&FilterValue1=' + [$Author.title] + '&FilterField2=My_x0020_DateColumn&FilterValue2=' + getYear([$Start])+'-'+getMonth([$Start])+'-'+getDate([$Start])" } } Edit 2
Month does seem to be 0 indexed, this seems to work:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "a", "txtContent": "*****", "attributes": { "target": "_blank", "href": "='https://*****.sharepoint.com/sites/group-*****/Lists/*****%20*****/AllItems.aspx?FilterField1=Person&FilterValue1=' + [$Author.title] + '&FilterField2=My_x0020_DateColumn&FilterValue2=' + getYear([$Start]) + '-' + (getMonth([$Start])+1) + '-' + getDate([$Start])" } } 
