Adaptive Cards Date Format dd/MM/yyyy Update

The date format dd/MM/yyyy now available for Adaptive Cards. There has been an update to the Adaptive Expression Language(AEL) so that the date format dd/MM/yyyy is rendered correctly, our Power BI Adaptive Cards visual (1/0/6) has been re-built and tested with version ^4.9.2 of AEL.

The variety of date formats, not to mention time zones, is a constant thorn in the side of UI designers. While I was testing an Adaptive Card in 2020 I came up with this problem: 

'If I have a Date like this: date: "2020-09-30T00:00:00.000Z"
and format like this: "text": "Date is ${formatDateTime(date, 'dd/MM/yyyy')}"
I get this rendered: Date is 30:09:2020

I expect 30/09/2020'

A bit of background here, I'm in Australia and we commonly use dd/MM/yyyy for dates as does the UK and France, Germany uses the ':' as a separator and in the US it's MM/dd/yyyy. I reported this problem as an Adaptive Cards issue which led to the problem being fixed.

This is not a simple problem but the fix seems pretty good and the Power BI Adaptive Cards visual version 1.0.6 with this upgrade is available in App Source. 

There is a test pbix available for download

Here's a sample: 

The card is also available for download

Let's run through these formats:

Format Output Explanation
{{DATE(${formatDateTime(dateInput, 'yyyy-MM-ddTHH:mm:ssZ' )})}} 9/30/2020 This was suggested the correct way format a date
{{DATE(${dateInput})}} {{DATE(${30-September-2020})}} Not supported so it just passes the string
${formatDateTime(dateInput, 'dd/MM/yyyy' ) 30/09/2020 Recommended solution, this is the fix
${formatDateTime(dateInput) 2020-09-20T14:00:00.00.000Z This is dangerous as it has converted the date to UTC and subtracted 10 hours!
${dateinput} 30-September-2020 For completeness, this is passing the date as formatted in Power BI, this is a good way to go as well


There does not appear to be a provision to format automatically by locale. There is a locale field in the formatDateTime function, don't use it, it crashes the visual. Neither the visual nor Adaptive Cards fully support the AEL, read the reference with that in mind.

Please don't hesitate to get in touch if you have any questions, and I will try to answer them.

Comments are closed