{"id":15205,"date":"2019-03-26T12:35:50","date_gmt":"2019-03-26T12:35:50","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=15205"},"modified":"2022-07-19T16:47:55","modified_gmt":"2022-07-19T11:17:55","slug":"converting-date-time-based-on-user-time-zone-in-power-app-dynamics-365-ce","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2019\/03\/converting-date-time-based-on-user-time-zone-in-power-app-dynamics-365-ce\/","title":{"rendered":"Converting Date and Time based on User Time Zone in PowerApp for Dynamics 365 CE"},"content":{"rendered":"<h2><strong>Introduction<\/strong><\/h2>\n<p>In our previous <a href=\"https:\/\/www.inogic.com\/blog\/2019\/02\/set-date-time-field-dynamics365-power-app\/\" target=\"_blank\" rel=\"noopener noreferrer\">blog<\/a> we have explored on how to set date and time fields of dynamics 365 through power app. Handling date and time fields according to time zone is quite tedious task. In today\u2019s blog we will explore more on how to handle date and time fields of dynamics 365 according to user time zone in power apps.<\/p>\n<p>The time zone of dynamics 365 instance is set as \u201cEastern Time\u201d as shown in below screenshot:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-15206\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/03\/1Converting-Date-and-Time-based-on-User-Time-Zone-in-Power-App-for-Dynamics-365-CE.png\" alt=\"Converting Date and Time based on User Time Zone in Power App for Dynamics 365 CE\" width=\"984\" height=\"633\" \/><\/p>\n<p>But my app is running on the phone where time zone is set as \u201cIndian Standard Time\u201d.<\/p>\n<p>Therefore, we cannot set correct time in the date and time fields due to time zone difference between dynamics 365 and powerapp.<\/p>\n<p>To solve this difference, follow the below steps for updating the date and time fields of records in dynamics 365 through power app:<\/p>\n<p><strong>1<\/strong>. Create a default Canvas app for appointment entity by using Dynamics 365. You can refer our previous blog\u00a0<a href=\"https:\/\/www.inogic.com\/blog\/2018\/07\/create-records-in-dynamics-365-with-canvas-powerapp\/\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a><\/p>\n<p><strong>2<\/strong>. Now add \u201cStart Date\u201d and \u201cEnd Date\u201d fields on the edit screen as shown in the below screenshot:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-15207\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/03\/2Converting-Date-and-Time-based-on-User-Time-Zone-in-Power-App-for-Dynamics-365-CE.png\" alt=\"Converting Date and Time based on User Time Zone in Power App for Dynamics 365 CE\" width=\"982\" height=\"675\" \/><\/p>\n<p><strong>3<\/strong>. Now on \u201c<strong>onSelect<\/strong>\u201d property of \u201c<strong>IconAccept<\/strong>\u201d<br \/>\n<img decoding=\"async\" class=\"alignleft wp-image-15211\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/03\/6Converting-Date-and-Time-based-on-User-Time-Zone-in-Power-App-for-Dynamics-365-CE.png\" alt=\"Converting Date and Time based on User Time Zone in Power App for Dynamics 365 CE\" width=\"21\" height=\"24\" \/>add patch formula as given below:<\/p>\n<p>Patch(<\/p>\n<p>Appointments,<\/p>\n<p>First(<\/p>\n<p>Filter(<\/p>\n<p>Appointments,<\/p>\n<p>activityid = BrowseGallery1.Selected.activityid<\/p>\n<p>)<\/p>\n<p>),<\/p>\n<p>{<\/p>\n<p>scheduledstart: If(<\/p>\n<p>IsBlank(DateValue1.SelectedDate),<\/p>\n<p>Blank(),<\/p>\n<p>DateAdd(<\/p>\n<p>DateValue1.SelectedDate + Time(<\/p>\n<p>Value(HourValue1.Selected.Value),<\/p>\n<p>Value(MinuteValue1.Selected.Value),<\/p>\n<p>0<\/p>\n<p>),<\/p>\n<p>TimeZoneOffset(),<\/p>\n<p>Minutes<\/p>\n<p>)<\/p>\n<p>),<\/p>\n<p>scheduledend: If(<\/p>\n<p>IsBlank(DateValue2.SelectedDate),<\/p>\n<p>Blank(),<\/p>\n<p>DateAdd(<\/p>\n<p>DateValue2.SelectedDate + Time(<\/p>\n<p>Value(HourValue2.Selected.Value),<\/p>\n<p>Value(MinuteValue2.Selected.Value),<\/p>\n<p>0<\/p>\n<p>),<\/p>\n<p>TimeZoneOffset(),<\/p>\n<p>Minutes<\/p>\n<p>)<\/p>\n<p>)<\/p>\n<p>}<\/p>\n<p>)<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-15208\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/03\/3Converting-Date-and-Time-based-on-User-Time-Zone-in-Power-App-for-Dynamics-365-CE.png\" alt=\"Converting Date and Time based on User Time Zone in Power App for Dynamics 365 CE\" width=\"1086\" height=\"623\" \/><\/p>\n<p>In the above formula we have implemented the \u201cDateAdd\u201d and \u201cTimeZoneOffSet()\u201d function to convert the data and time value into UTC format.<\/p>\n<ul>\n<li>DataAdd: The\u00a0<strong>DateAdd<\/strong>function adds a number of units to a date\/time value.<\/li>\n<li>TimeZoneOffSet : The\u00a0<strong>TimeZoneOffset<\/strong>function returns difference between the user&#8217;s local time and UTC in minutes.<\/li>\n<\/ul>\n<p><strong>4<\/strong>. Let\u2019s run the app and set \u201c<strong>Start Time<\/strong>\u201d and \u201c<strong>End Time<\/strong>\u201d for a record in CRM through PowerApp by selecting\u00a0<img decoding=\"async\" class=\"wp-image-15211 alignleft\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/03\/6Converting-Date-and-Time-based-on-User-Time-Zone-in-Power-App-for-Dynamics-365-CE.png\" alt=\"Converting Date and Time based on User Time Zone in Power App for Dynamics 365 CE\" width=\"20\" height=\"22\" \/> in powerApp.<\/p>\n<p style=\"padding-left: 150px;\"><img decoding=\"async\" class=\"aligncenter wp-image-15209\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/03\/4Converting-Date-and-Time-based-on-User-Time-Zone-in-Power-App-for-Dynamics-365-CE.png\" alt=\"Converting Date and Time based on User Time Zone in Power App for Dynamics 365 CE\" width=\"358\" height=\"633\" \/><\/p>\n<p><strong>5<\/strong>. Now as shown below the \u201cStart Time\u201d and \u201cEnd Time\u201d values are updated in CRM in Eastern Time:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-15210\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/03\/5Converting-Date-and-Time-based-on-User-Time-Zone-in-Power-App-for-Dynamics-365-CE.png\" alt=\"Converting Date and Time based on User Time Zone in Power App for Dynamics 365 CE\" width=\"822\" height=\"545\" \/><\/p>\n<h2>Conclusion<\/h2>\n<p>PowerApps allows user to handle date and time fields of dynamics 365 according to user time zone.<\/p>\n<h2 style=\"text-align: left;\"><div class=\"su-heading su-heading-style-default su-heading-align-center\" id=\"\" style=\"font-size:15px;margin-bottom:5px\"><div class=\"su-heading-inner\">70% of global 2000 companies apply gamification to improve productivity and returns!<\/div><\/div><\/h2>\n<p><em><strong><a href=\"https:\/\/bit.ly\/3RD4lYW\" target=\"_blank\" rel=\"noopener noreferrer\">Gamifics365<\/a> <\/strong>\u2013 Spin the magic of games within Microsoft Dynamics 365 CRM to improve user adoption, enhance productivity, and achieve company goals!<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction In our previous blog we have explored on how to set date and time fields of dynamics 365 through power app. Handling date and time fields according to time zone is quite tedious task. In today\u2019s blog we will explore more on how to handle date and time fields of dynamics 365 according to\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2019\/03\/converting-date-time-based-on-user-time-zone-in-power-app-dynamics-365-ce\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":15212,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[16,18,19,38],"tags":[1170,1352,1354],"class_list":["post-15205","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dynamics-365","category-dynamics-365-v9-2","category-dynamics-crm","category-microsoft-powerapps","tag-microsoft-powerapps","tag-powerapps-dynamics-365-ce","tag-powerapps-dynamics-crm"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/15205","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=15205"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/15205\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media\/15212"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=15205"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=15205"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=15205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}