cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
yashaikh
Frequent Visitor

Power Automate Microsoft Flow does not retrieve correct UTC 00 value of Date Only field or does not convert to correct time zone value

I am having an issue in MS Flow while retrieving the value of expirydate field of type Date Only from a custom entity. My Time zone in personalized settings is UTC +12 (New Zealand Standard Time)

 

  1. On the UI of model driven app, I had entered the following value and the app still correctly show expirydate field value:

expirydate (Date Only) = 30/6/2021 (this field has behaviour set to User Local)

 

  1. By exporting custom entity record in excel from make.powerapps.com, I can see the following values:

created on (Date Time) = 2021-05-01T10:25:20Z         (this I mentioned to let you know when the record was actually created)

expirydate (Date Only) = 2021-06-29T12:00:00Z  (this seems to be correct in UTC 00 as for Date Only fields time part is dropped and hence it first changes from 2021-06-30T10:25:20Z to 2021-06-30T00:00:00Z, then while storing it in Dataverse it is converted to UTC 00, therefore it changes from 2021-06-30T00:00:00Z to 2021-06-29T12:00:00Z which is exactly a 12 hours difference. 

 

  1. when I retrieve the record using microsoft flow, instead of getting the Dataverse stored UTC 00 value 2021-06-29T12:00:00Z, I am getting following:

 

expirydate (Date Only) = 2021-06-29T00:00:00.0000000Z (missing time portion of 12 hours)

 

Therefore when I convert 2021-06-29T00:00:00.0000000Z to UTC +12 using convertTimeZone function, the date remains 29 and doesn't change back to 30 because 2021-06-29T00:00:00.0000000Z does not contain  offset portion of 12 hours which I had retrieved by exporting it in Excel in step 2.

 

I have tried following as well but nothing works:

 

convertTimeZone(concat(triggerBody()?['expirydate'],'Z'),'UTC','New Zealand Standard Time','yyyy-MM-ddTHH:mm:ss.fffffffZ')

 

convertFromUtc(formatDateTime(triggerBody()?['expirydate'],'yyyy-MM-ddTHH:mm:ss.fffffffZ'),'New Zealand Standard Time','F')

 

convertFromUtc(concat(triggerBody()?['expirydate'],'Z'),'New Zealand Standard Time','F')

 

 

All I need is to successfully convert the expirydate into correct UTC +12 value which is 2021-06-30T00:00:00Z and thats only possible when I will retrieve correct UTC 00 value 2021-06-29T12:00:00Z of expirydate field in Microsoft Flow. 

 

Anyone can please let me know how I can achieve this?

 

 

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
yashaikh
Frequent Visitor

OK, I have found the solution for this problem with a hit and trial logic. Actually this is a Microsoft bug in Power Automate. What happens is for Date Only fields having behavior set  to User Local doesn't retrieve the time component stored in Dataverse when the Microsoft Flow triggers.

 

In my above scenario, MS Flow fetches 6/29 instead of 6/29 12:00 PM when the flow triggers on "when a reocrd is updated" , which is why convertTimeZone function is not able to convert 6/29 to 6/30. The way around for this problem is to fetch the same record using Dataverse component "Get a Row" in Microsoft Flow, this time it will bring time component of all Date Only fields having behavior set to User Local. Once you get the time component , you are good to go using convertTimeZone function to convert the value in respective zone.

 

 

Following is the behavior when the flow triggers, I had used the 13 May on UI but it returns 12 May without time component:

yashaikh_2-1620871310020.png

 

And when I fetch the same record again, it returns the time component, i.e. 12 May 12:00 PM

 

yashaikh_3-1620871472692.png

 

 

Regards,

 

 

 

View solution in original post

13 REPLIES 13
Pstork1
Dual Super User III
Dual Super User III

Just to be clear.  2021-06-29T12:00:00Z  is a date only field that has already been adjusted for New Zealand Time zone.  A Date only field in actual UTC would be 2021-06-29T00:00:00Z  12:00:00Z is noon in UTC.  00:00:00Z is midnight.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
yashaikh
Frequent Visitor

If 2021-06-29T12:00:00Z is already adjusted to New Zealand Time Zone, then why it is adjusted again as 30/6/2021 on the UI of model driven app. Therefore I believe 2021-06-29T12:00:00Z is not in New Zealand Time Zone, rather a UTC 00 value

yashaikh
Frequent Visitor

@rrovira , @Mari , @ajdhingr , or anyone else,  can you please look into my query?

Pstork1
Dual Super User III
Dual Super User III

As I said, 00:00:00Z is midnight UTC.  12:00:00Z is noon.  New Zealand time Zone is +12 UTC.  So Midnight in UTC is noon in New Zealand.  YOu said in the UI of the Model driven app it was set to User.local by the UI.  So when the user enters the time it is automatically translated from user.local to UTC.  That's why you are seeing the value stored as 12:00:00Z.  The 12:00:00Z is in UTC the same time as midnight in user.local.  When you read the value in Power Automate it is reading the UTC value as stored and is not adjusting back to user.local.  Since User.local in New Zealand is UTC+12 you need to add 12 to the 12:00:00Z which should result in 00:00:00Z + one day.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
yashaikh
Frequent Visitor

@Pstork1 I do know and understand 00:00:00Z is midnight UTC and 12:00:00Z is noon, and I have already tried adding 12 in what is read by Power Automate. The Power Automate Flow currently reads 2021-06-29T00:00:00.0000000Z and adding 12 converts it in 2021-06-29T12:00:00.0000000Z but not 2021-06-30T00:00:00.0000000Z, and my point is Power Automate should read the value 2021-06-29T12:00:00.0000000Z from Dataverse in first place, then only when 12 is added,  it will change to 2021-06-30T00:00:00.0000000Z. Let me know if I am still thinking wrong.

 

My second point is, why do I require to add 12 manually ? I was expecting this from converTimeZone function or from converFromUTc function.

Pstork1
Dual Super User III
Dual Super User III

Is the column in Dataverse defined as a date only column?  If it is then its dropping the time portion of the date when it is saved.  So here is what I think is happening.

1) User inputs 6/30 midnight local time.

2) The UI converts that to 6/29 noon UTC and stores in in Dataverse

3) Dataverse truncates it and stores 6/29 midnight since its a date only column.

4) Flow retrieves the date only column 6/29 midnight.

 

There are also settings in the Dataverse column that control what it stores.  Verify what your settings are on that column.  Here's an excerpt from the documentation.

Behavior and format of the Date and Time column in Microsoft Dataverse - Power Apps | Microsoft Docs

Date and time column behavior and format

The following table contains information about the date and time column behavior and format.

DATE AND TIME COLUMN BEHAVIOR AND FORMAT
Behavior Format Description
User Local Date Only
- or -
Date and Time
This is the default behavior of custom date and time columns.

The column values are displayed in the current user's local time.
In Web services, these values are returned using a common UTC time zone format.

You can change this one time if you select the default behavior. More information Change User Local Behavior
Date Only Date Only No Time zone conversion.

The time portion of the value is always 12:00AM.
The date portion of the value is stored and retrieved as specified in the UI and Web services.
Time-Zone Independent Date Only
- or -
Date and Time
No Time zone conversion.

The date and time values are stored and retrieved as specified in the UI and Web services.


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
yashaikh
Frequent Visitor

In point 4 you said "Flow retrieves the date only column 6/29 midnight." , if that is true then why Excel Data is showing 2021-06-29T12:00:00.0000000Z which is the correct representation of Dataverse. I am claiming this as correct representation of Dataverse because UI is able to successfully convert this value into 2021-06-30T00:00:00.0000000Z by adding +12 using whatever logic, be it a convertTimeZone function or convertFromUTc function. As explained already in my first post, let me reiterate what is happening which I believe:

 

1.  As a user I provided value 6/30 on UI (we can assume it with current time or without current time i.e. 2021-06-30T10:25:20.0000000Z OR 2021-06-30T00:00:00.0000000Z, but time portion will be dropped.)

2. The logic lying between UI and Dataverse drops the time portion of 6/30 and converts it from UTC New Zealand to UTC only, i.e. 2021-06-30T00:00:00.0000000Z is converted to 2021-06-29T12:00:00.0000000Z

3. As a final step 2021-06-29T12:00:00.0000000Z is stored in Dataverse.

 

If you still convinced that Dataverse is storing 2021-06-29T00:00:00.0000000Z instead of 2021-06-29T12:00:00.0000000Z, then are you trying to say that when UI displays back the value to user, it is adding 1 full day to convert it back to UTC New Zealand? If yes, then that is not I am convinced with because on what basis the logic is trying to add 1 full day, since the difference between the UTC and UTC New Zelanad is only 12 hours.

 

 

Secondly I had asked a question, why do I manually need to adjust hours to convert the value in local time zone? why can't I use convertTimeZon function or convertFromUTc function?

Pstork1
Dual Super User III
Dual Super User III

Excel and Dataverse handle Date and Time differently.  Did you check the behavior settings on the column to compare it to the chart I posted from the documentation?  I believe the key here is #3 in the list where Dataverse is truncating the Date and Time to Date Only.  That effectively changes the local time of Noon on 6/29 to Midnight on 6/29.  When you convert it back it converts back to Noon on 6/29 not Midnight on 6/30.  For most time zones it would be clearer, but since New Zealand is exactly 1/2 day off it becomes less clear what is happening.  Please check the Behavior settings on the column and compare those to the chart I posted.

 

The key is in your #1.  The User.local to UTC Time zone conversion is taking place BEFORE the time portion is dropped.  So when it comes out and the TimeZone is converted back its the wrong day.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
yashaikh
Frequent Visitor

If dataverse has stored 6/29 midnight, then by what logic UI is able to successfully convert it to 6/30? Unless it adds 24 hours, it won't change to 6/30 and this is why I am not convinced UI would be adding exactly 24 hours because there is no reason of doing hard coded logic instead of time zone conversion logic, and hence it tempts me to believe dataverse is storing 6/29 noon.

 

 

The behaviour of expirydate field I had already mentioned in the first post i.e. User Local. 

Pstork1
Dual Super User III
Dual Super User III

But that's exactly your problem.  Because the field is being truncated to Date Only when its stored there is no way to get it back to 6/30 using a Time zone shift.

 

Did you check the Behavior settings on the column and compare those to the chart I posted.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
yashaikh
Frequent Visitor

When I hard code to add 1 day in 6/29 (exiprydate), it successfully converts the value to New Zealand Standard Time. After that when I change the Time Zone to USA and create a new records, the logic of adding 1 day in expirydate fails and converts the value 1 day ahead, i.e. 31/29

 

Behaviour settings i already explained that it is set as User Local and Format is set to Date Only. I cannot use other settings for my specific requirement.

 

yashaikh
Frequent Visitor

OK, I have found the solution for this problem with a hit and trial logic. Actually this is a Microsoft bug in Power Automate. What happens is for Date Only fields having behavior set  to User Local doesn't retrieve the time component stored in Dataverse when the Microsoft Flow triggers.

 

In my above scenario, MS Flow fetches 6/29 instead of 6/29 12:00 PM when the flow triggers on "when a reocrd is updated" , which is why convertTimeZone function is not able to convert 6/29 to 6/30. The way around for this problem is to fetch the same record using Dataverse component "Get a Row" in Microsoft Flow, this time it will bring time component of all Date Only fields having behavior set to User Local. Once you get the time component , you are good to go using convertTimeZone function to convert the value in respective zone.

 

 

Following is the behavior when the flow triggers, I had used the 13 May on UI but it returns 12 May without time component:

yashaikh_2-1620871310020.png

 

And when I fetch the same record again, it returns the time component, i.e. 12 May 12:00 PM

 

yashaikh_3-1620871472692.png

 

 

Regards,

 

 

 

View solution in original post

yashaikh
Frequent Visitor

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

Users online (41,060)