c# - Azure Logic App Expression-convertTimeZone() is failed -Conversion from 02:00 AM CETCEST to UTC - Stack Overflow

admin2025-05-02  1

Objective:

Convert CET/CEST time to UTC

Used below logic app expression:

convertTimeZone('timestamp', 'sourceTimeZone', 'destinationTimeZone', 'format'?)

My Logic app Design as below:

HTTP trigger and a compose action to convert the DateTime.

Workflow Image

TriggerBody

Issue-1

Testing 2024-10-27T01:00:00 CEST time and the converted UTC timestamp is 2024-10-26T23:00:00+00:00. Which is correct and as expected. CEST-02:00 = UTC.

ExpectedConversion&Valid

Testing 2024-10-27T02:00:00 which is either CEST or CET. The conversion failed with below error.

Unable to process template language expressions in action 'ConvertedDateTime' inputs at line '0' and column '0': 'The template language function 'convertTimeZone' was given a timestamp '2024-10-27T02:00:00.0000000' that was invalid or ambiguous in the source time zone 'W. Europe Standard Time'.'.

Failed Conversion

Is there any format am i missing in the input here???

Logic app supposed to consider this timestamp (2024-10-27T02:00:00) either in CEST or CET and convert into UTC, isn't???

Issue-2

The converted time stamp doesn't include the timezone offset info.

Converting UTC > IST. IST is ahead of 05:30 hours than UTC. Input provided 2025-01-01T00:00:00 and expected was 2025-01-01T05:30:00+05:30 but the result is 2025-01-01T05:30:00+00:00. The time is converted but no timezone info set.

TimeZoneOffsetMissing

Referred below MS docs for all these

Objective:

Convert CET/CEST time to UTC

Used below logic app expression:

convertTimeZone('timestamp', 'sourceTimeZone', 'destinationTimeZone', 'format'?)

My Logic app Design as below:

HTTP trigger and a compose action to convert the DateTime.

Workflow Image

TriggerBody

Issue-1

Testing 2024-10-27T01:00:00 CEST time and the converted UTC timestamp is 2024-10-26T23:00:00+00:00. Which is correct and as expected. CEST-02:00 = UTC.

ExpectedConversion&Valid

Testing 2024-10-27T02:00:00 which is either CEST or CET. The conversion failed with below error.

Unable to process template language expressions in action 'ConvertedDateTime' inputs at line '0' and column '0': 'The template language function 'convertTimeZone' was given a timestamp '2024-10-27T02:00:00.0000000' that was invalid or ambiguous in the source time zone 'W. Europe Standard Time'.'.

Failed Conversion

Is there any format am i missing in the input here???

Logic app supposed to consider this timestamp (2024-10-27T02:00:00) either in CEST or CET and convert into UTC, isn't???

Issue-2

The converted time stamp doesn't include the timezone offset info.

Converting UTC > IST. IST is ahead of 05:30 hours than UTC. Input provided 2025-01-01T00:00:00 and expected was 2025-01-01T05:30:00+05:30 but the result is 2025-01-01T05:30:00+00:00. The time is converted but no timezone info set.

TimeZoneOffsetMissing

Referred below MS docs for all these https://learn.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#converttimezone https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/default-time-zones?view=windows-11

Share Improve this question edited Jan 2 at 14:54 asked Jan 2 at 13:46 user27317901user27317901 3
  • 1 The problem is that the timestamp 2024-10-27T02:00:00 exists in both CET and CEST and it's not possible to know which one it is without the explicit timezone information. – phuzi Commented Jan 2 at 15:13
  • Yeah, I agree to your answer. Thought of check, is there any default implementation in .NET to consider it as CEST or CET. – user27317901 Commented Jan 3 at 5:39
  • @phuzi Regarding the issue-2, any idea, why the offset value is always +00:00 instead of the destination offset? – user27317901 Commented Jan 3 at 5:40
Add a comment  | 

1 Answer 1

Reset to default 0

The converted time stamp doesn't include the timezone offset info. Converting UTC > IST. IST is ahead of 05:30 hours than UTC. The time is converted but no timezone info set.

You need to use custom formatting include the offset like using below design:

concat(variables('var'),'+',formatDateTime(convertTimeZone(variables('var'), 'UTC', 'India Standard Time'),'HH:mm:ss'))

Output:

Testing 2024-10-27T01:00:00 CEST time and the converted UTC timestamp is 2024-10-26T23:00:00+00:00. Which is correct and as expected. CEST-02:00 = UTC. Testing 2024-10-27T02:00:00 which is either CEST or CET. The conversion failed with below error.

This happens because DST Transition on that day. To make it work you need to add offset.

addToTime('2024-10-27T02:00:00', 1, 'Hour')

Output:

转载请注明原文地址:http://anycun.com/QandA/1746117070a91904.html