cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
r529
Level: Powered On

Passing date field to Dynamics 365 datetime field

I've seen quite a few postings about correctly handling datetime fields, but none of them seem to solve my problem.

 

I'm trying to write to the msdyn_date attribute of the msdyn_timeentry entity in Dynamics 365 (part of Project Serivce Automation).  When I query the data that has been created via the regular UI through the web api, the dates are in a format like this:  

"msdyn_date":"2018-12-12T06:00:00Z"

I assume that the datetime PowerApps needs to pass should be in this same form with the correct time zone offset.  To do this the update property of the applicable data card is this:

 

Text(DateAdd(DataCardValue2.SelectedDate,TimeZoneOffset(Today()),Minutes),"[$-en-US]yyyy-mm-ddThh:mm:ssZ") 

 

I duplicated the above in a label for testing purposes and it seems to yield the correct result.  As an exmple, on 12/13/2018 in the Central Time Zone of the US, this value displayed in the label is:  2018-12-13T06:00:00Z.  

However when I query the created record through the web api, the date in that record is 2018-12-13T00:00:00Z, i.e. the time zone got lost along the way.  

 

What is the correct way I should be formatting the date field to post correctly?  The app is a canvas app.

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Passing date field to Dynamics 365 datetime field

Hi @r529,

Does your Dynamics 365 environment have same Time Zone as your local time zone?

Could you please share a screenshot about your app's configuration?

When storing date time value in Dynamics 365, the date time value would be stored in UTC time zone format. But when you see it within your Dynamics 365, this value would be converted to your local time zone.

So on your side, if the Time Zone of your Dynamics 365 has been set to your local time zone, the  2018-12-13T06:00:00Z value would be stored as a UTC Time Zone format, when you see it within your D365, this value would be converted into your local time zone -- 2018-12-13T00:00:00Z.

As an alternative soltuion, you could consider modify the Text formula within your app as below:

Text(
DateAdd(DataCardValue2.SelectedDate,TimeZoneOffset(Today())*2,Minutes),
"[$-en-US]yyyy-mm-ddThh:mm:ssZ"
)

then check if the issue is solved on your side.

In addition, you could also consider take a try to add a Text type column within your D365 entity to store the Date Time value passed from your app instead of Date Time type column, after that, you don't need to care about the Time Zone issue, you could store the Date Time value into this Text Type column directly.

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Community Support Team
Community Support Team

Re: Passing date field to Dynamics 365 datetime field

Hi @r529,

Does your Dynamics 365 environment have same Time Zone as your local time zone?

Could you please share a screenshot about your app's configuration?

When storing date time value in Dynamics 365, the date time value would be stored in UTC time zone format. But when you see it within your Dynamics 365, this value would be converted to your local time zone.

So on your side, if the Time Zone of your Dynamics 365 has been set to your local time zone, the  2018-12-13T06:00:00Z value would be stored as a UTC Time Zone format, when you see it within your D365, this value would be converted into your local time zone -- 2018-12-13T00:00:00Z.

As an alternative soltuion, you could consider modify the Text formula within your app as below:

Text(
DateAdd(DataCardValue2.SelectedDate,TimeZoneOffset(Today())*2,Minutes),
"[$-en-US]yyyy-mm-ddThh:mm:ssZ"
)

then check if the issue is solved on your side.

In addition, you could also consider take a try to add a Text type column within your D365 entity to store the Date Time value passed from your app instead of Date Time type column, after that, you don't need to care about the Time Zone issue, you could store the Date Time value into this Text Type column directly.

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

r529
Level: Powered On

Re: Passing date field to Dynamics 365 datetime field

Thanks for your help.  

 

For the time zone question, if you're referring to my user time zone setting, it is set to my local time zone.  I was familiar with how D365 store datetime in UTC and how it coverts it at rendering in the UI.  That is what made me suspect something was missing with the time zone offset portion.  When I pulled the relevant record through the Web API, the time zone offset was missing for those records created through the Power App but not those created through the regular UI.

 

I've attached a screenshot.  I will also try the first alternative your provided. 

 

I'm hesitant to create a second date attribute in D365 as a workaround.

 

 

 

 

r529
Level: Powered On

Re: Passing date field to Dynamics 365 datetime field

The expression you provided serms to have worked. Thanks.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (5,320)