You're encountering a common timezone issue with date/time conversions in Power Automate. Even though you're setting the time to 11:59 PM, the flow is interpreting and storing it in UTC, and then Dataverse is displaying it based on your user's timezone (UTC-05:00), resulting in the 6-hour difference.
Here's how to fix it within your Power Automate flow:
1. Specify Timezone in parseDateTime
(Crucial):
The parseDateTime
function can take a timezone parameter, but you're currently using en-US
for the locale, not the timezone. You must explicitly tell the function that your input date/time string is already in a specific timezone before converting it to UTC.
Since your date string doesn't include timezone information, Power Automate assumes it's in the current timezone of the flow's execution environment (which is often UTC).
2. Set the Timezone to UTC-05:00 for the parseDateTime
function:
- 'America/New_York': Replace this with the appropriate IANA timezone name that corresponds to UTC-05:00. Using
America/New_York
is an example. You should find the IANA name for your specific region that uses UTC-05:00.
3. Convert to UTC (If Necessary):
If your Dataverse DateTime field is stored in UTC (which is recommended), you might need to explicitly convert the parsed date/time to UTC after parsing it in the compose action. However, the above step should handle the conversion.
4. Update Record:
When you update the Dataverse record, the DateTime value you're sending should now be correctly interpreted as 11:59 PM in your specified timezone. Dataverse will store it in UTC, but display it correctly in your user's timezone.
Complete Example (Compose Action Expression):
parseDateTime(concat(triggerOutputs()?['body/retentiondate'], 'T23:59:59.000'), 'yyyy-MM-ddTHH:mm:ss.fff', 'America/New_York')
Explanation:
- By including the timezone parameter (
'America/New_York'
) in the parseDateTime
function, you're telling Power Automate that the input date and time are in that timezone.
- Power Automate will then correctly convert this to UTC before storing it in Dataverse.
- When Dataverse displays the date/time, it will convert it back to your user's timezone (UTC-05:00), showing the correct 11:59 PM time.
If my answer was helpful, please click Like, and if it solved your problem, please mark it as verified to help other community members find more. If you have further questions, please feel free to contact me.
My response was crafted with AI assistance and tailored to provide detailed and actionable guidance for your Microsoft Dynamics 365 query.
Best Regards,
Daivat Vartak