Reputation: 41
I have created an API which creates an excel having Date columns too. When I execute the code from local it works well and displays the date as expected.
When I try executing API via Logic App, it changes the date format of that field. How can I set date time in Logic App?
Upvotes: 4
Views: 31424
Reputation: 874
Logic apps time zone base on UTC. So, it needs conversion between UTC to your local time.
In my case, 'SE Asia Standard Time', (UTC+07:00); Bangkok, Hanoi, Jakarta. So, you need to convert it as your local time. Here's in my case:
Date convertTimeZone(utcNow(), 'UTC', 'SE Asia Standard Time', 'MMMM dd, yyyy')
;
Time convertTimeZone(utcNow(), 'UTC', 'SE Asia Standard Time','hh:mm:ss.ff tt')
Upvotes: 0
Reputation: 1416
I found some useful documentation on Microsoft's site here:
https://learn.microsoft.com/en-us/azure/kusto/query/format-datetimefunction
Here it is .. in action:
Upvotes: 2
Reputation: 2110
When you have a fixed DateTime-Format you can use the Logic App function "formatDateTime" as follow:
formatDateTime(triggerBody()?['myDate'], 'yyyy-MM-dd')
You can find it under Expressions - Date and Time - "See more" - formatDateTime
Upvotes: 8
Reputation: 15621
The problem is your local machine is running a different Locale than the machine running your code when it is deployed.
You could either set the CultureInfo.CurrentCulture to make sure the right CultureInfo is used.
CultureInfo...
Provides information about a specific culture (called a locale for unmanaged code development). The information includes the names for the culture, the writing system, the calendar used, the sort order of strings, and formatting for dates and numbers.
You could also use the appropriate DateTimeFormatInfo, when writing the date to Excel, it
Provides culture-specific information about the format of date and time values.
Upvotes: 1