{"id":4075,"date":"2021-02-14T03:47:06","date_gmt":"2021-02-14T03:47:06","guid":{"rendered":"https:\/\/himbap.com\/blog\/?p=4075"},"modified":"2021-02-14T03:47:06","modified_gmt":"2021-02-14T03:47:06","slug":"dynamics-365-ce-date-conversion-in-power-automate","status":"publish","type":"post","link":"https:\/\/himbap.com\/blog\/?p=4075","title":{"rendered":"Dynamics 365 CE Date Conversion in Power Automate"},"content":{"rendered":"<p><strong>Problem<\/strong><br \/>\nRecently while working on Power Automate to send notification if custom activity record is completed before 15 day but still invoicing is not done yet, I was facing time zone issue while comparing date. I will provide details how I sold this issue.<\/p>\n<p><strong>Solution<\/strong><br \/>\nInitially I started creating my flow where I used Recurrence and fetched my entity records based on the condition. After that I started comparing date using expression like below:<br \/>\n<a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2021\/02\/FormatDate.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-4082 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2021\/02\/FormatDate-288x300.png\" alt=\"FormatDate\" width=\"288\" height=\"300\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2021\/02\/FormatDate-288x300.png 288w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2021\/02\/FormatDate.png 584w\" sizes=\"(max-width: 288px) 100vw, 288px\" \/><\/a><\/p>\n<p>1. Here I formatted date from CRM to match particular format<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nformatDateTime(items('Apply_to_each')?['modifiedon'],'yyyy-MM-dd')\r\n<\/pre>\n<p>2. Here I formatted the date I want to compare in the same format (15 days before current date)<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\naddDays(utcNow(),-15,'yyyy-MM-dd')\r\n<\/pre>\n<p>But result was not coming correctly, while troubleshooting I printed date on a temp variable but dates were not coming correctly. There was difference in the date. While doing troubleshooting further I found we can use Convert Time zone action to convert date time to specific time zone, so I changed my flow like below<br \/>\n<a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2021\/02\/FormatDate1.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-4083 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2021\/02\/FormatDate1-232x300.png\" alt=\"FormatDate1\" width=\"232\" height=\"300\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2021\/02\/FormatDate1-232x300.png 232w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2021\/02\/FormatDate1.png 608w\" sizes=\"(max-width: 232px) 100vw, 232px\" \/><\/a><\/p>\n<p>After that I got date formatted correctly.<\/p>\n<p><strong>Summary<\/strong><br \/>\nWhile working on the date comparison CRM date and the other date can be on the different format, you can use variable to print them and see if they are coming different format. If yes, you can use Convert Time Zone action.<\/p>\n<p>Hope it will help someone!<br \/>\n<strong>Keep learning, Keep sharing !!<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Problem Recently while working on Power Automate to send notification if custom activity record is completed before 15 day but still invoicing is not done yet, I was facing time zone issue while comparing date. I will provide details how I sold this issue. Solution Initially I started creating my flow where I used Recurrence and fetched my entity records&#8230; <a href=\"https:\/\/himbap.com\/blog\/?p=4075\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":4086,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[21,402,522,593,728],"tags":[856,857,838,858],"_links":{"self":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4075"}],"collection":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4075"}],"version-history":[{"count":4,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4075\/revisions"}],"predecessor-version":[{"id":4087,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4075\/revisions\/4087"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/media\/4086"}],"wp:attachment":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4075"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4075"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4075"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}