datetimeazure-logic-appsdate-conversionformatdatetime

How to change UK date format in LogicApp


Im trying to convert a U.K. input date (dd-MM-yyyy) to format (yyyy-MM-dd)

I tried

"@formatDateTime('15-03-2019','yyyy-MM-dd')" ==> Error

but got error:

'In function 'convertTimeZone', the value provided 
for date time string '15-03-2019' was not valid. The datetime 
string must match ISO 8601 format.'

How do I go about converting this input date? The input format is (dd-MM-yyyy) and cannot be changed.

I can easily convert from (MM-dd-yyyy) as shown below, but im not able to convert from (dd-MM-yyyy)

"@formatDateTime('03-15-2019','yyyy-MM-dd')" ==> OK

Solution

  • Date and time functions provided by azure logic app cannot recognize the timestamp in dd-MM-yyyy format.

    After my research, there is no existing function that can directly solve this problem, but you can use substring and concat to deal with this problem.

    The workflow of the logic app looks like this:

    enter image description here

    The expression of the formatDataTime:

    formatDateTime(concat(substring(<your-date-string>,6,4),'-',substring(<your-date-string>,3,2),'-',substring(<your-date-string>,0,2)),'yyyy-MM-dd')