{"id":133,"date":"2024-09-19T11:09:24","date_gmt":"2024-09-19T18:09:24","guid":{"rendered":"https:\/\/gilosoftblogcom.wordpress.com\/?p=133"},"modified":"2024-09-24T17:49:55","modified_gmt":"2024-09-24T17:49:55","slug":"finding-difference-in-dates-in-power-automate","status":"publish","type":"post","link":"https:\/\/blog.gilosoft.com\/index.php\/2024\/09\/19\/finding-difference-in-dates-in-power-automate\/","title":{"rendered":"The latest way of Finding difference in Dates in Power Automate"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Finding differences in dates can be a useful skill in different scenarios where one might need to know the years, months, or days between two different dates. Thankfully Power Automate has a simple solution using the dateDifference() expression. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this blog, we will go through how to create a simple flow that will use the dateDifference() expression to check two different dates using Power Automate. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here is the syntax for the dateDifference() expression:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndateDifference('&lt;startDate&gt;', '&lt;endDate&gt;')\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 1:<\/strong> Create A New instant cloud flow in your M365 Environment.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1636\" height=\"1044\" src=\"https:\/\/blog.gilosoft.com\/wp-content\/uploads\/2024\/09\/screenshot-2024-09-18-at-2.49.01e280afpm.png?w=1024\" alt=\"\" class=\"wp-image-138\" srcset=\"https:\/\/blog.gilosoft.com\/wp-content\/uploads\/2024\/09\/screenshot-2024-09-18-at-2.49.01e280afpm.png 1636w, https:\/\/blog.gilosoft.com\/wp-content\/uploads\/2024\/09\/screenshot-2024-09-18-at-2.49.01e280afpm-300x191.png 300w, https:\/\/blog.gilosoft.com\/wp-content\/uploads\/2024\/09\/screenshot-2024-09-18-at-2.49.01e280afpm-1024x653.png 1024w, https:\/\/blog.gilosoft.com\/wp-content\/uploads\/2024\/09\/screenshot-2024-09-18-at-2.49.01e280afpm-768x490.png 768w, https:\/\/blog.gilosoft.com\/wp-content\/uploads\/2024\/09\/screenshot-2024-09-18-at-2.49.01e280afpm-1536x980.png 1536w\" sizes=\"auto, (max-width: 1636px) 100vw, 1636px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 2:<\/strong> Add a compose action card with the following details.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndateDifference('2014-09-08T10:30:00', '2024-07-30T14:45:30')\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1844\" height=\"576\" src=\"https:\/\/blog.gilosoft.com\/wp-content\/uploads\/2024\/09\/screenshot-2024-09-18-at-2.56.38e280afpm.png?w=1024\" alt=\"\" class=\"wp-image-140\" style=\"width:680px;height:auto\" srcset=\"https:\/\/blog.gilosoft.com\/wp-content\/uploads\/2024\/09\/screenshot-2024-09-18-at-2.56.38e280afpm.png 1844w, https:\/\/blog.gilosoft.com\/wp-content\/uploads\/2024\/09\/screenshot-2024-09-18-at-2.56.38e280afpm-300x94.png 300w, https:\/\/blog.gilosoft.com\/wp-content\/uploads\/2024\/09\/screenshot-2024-09-18-at-2.56.38e280afpm-1024x320.png 1024w, https:\/\/blog.gilosoft.com\/wp-content\/uploads\/2024\/09\/screenshot-2024-09-18-at-2.56.38e280afpm-768x240.png 768w, https:\/\/blog.gilosoft.com\/wp-content\/uploads\/2024\/09\/screenshot-2024-09-18-at-2.56.38e280afpm-1536x480.png 1536w\" sizes=\"auto, (max-width: 1844px) 100vw, 1844px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 3:<\/strong> Save &amp; Test the flow. Your results should be as shown below.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1102\" height=\"698\" src=\"https:\/\/blog.gilosoft.com\/wp-content\/uploads\/2024\/09\/screenshot-2024-09-18-at-2.58.07e280afpm.png?w=1024\" alt=\"\" class=\"wp-image-142\" srcset=\"https:\/\/blog.gilosoft.com\/wp-content\/uploads\/2024\/09\/screenshot-2024-09-18-at-2.58.07e280afpm.png 1102w, https:\/\/blog.gilosoft.com\/wp-content\/uploads\/2024\/09\/screenshot-2024-09-18-at-2.58.07e280afpm-300x190.png 300w, https:\/\/blog.gilosoft.com\/wp-content\/uploads\/2024\/09\/screenshot-2024-09-18-at-2.58.07e280afpm-1024x649.png 1024w, https:\/\/blog.gilosoft.com\/wp-content\/uploads\/2024\/09\/screenshot-2024-09-18-at-2.58.07e280afpm-768x486.png 768w\" sizes=\"auto, (max-width: 1102px) 100vw, 1102px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The results are in a <strong>Days.Hours:Minutes:Seconds <\/strong>format<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now what if you wanted to Extract certain values from your result such as days, hours, minutes, or seconds. This can be done by using the split () function.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To fully understand the different parts of the expression we will use to extract the days follow the below explanation.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The&nbsp;<code>split()<\/code>&nbsp;function splits the output of dateDifference() at the period (\u2018.\u2019) into an array with two elements: days and the rest (hours:minutes:seconds).<\/li>\n\n\n\n<li>The&nbsp;<code>[0]<\/code>&nbsp;indexer retrieves the first element of the array, which represents the number of days.<\/li>\n\n\n\n<li>The&nbsp;<code>int()<\/code>&nbsp;function converts the days from a string to an integer.<\/li>\n\n\n\n<li>Replace the date time values with your dates\/time<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Extract Days<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To extract the days value from the result use the expression shown below in a compose action card  and your result will be as shown in the compose action card.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nint(split(split(dateDifference('2014-09-08T10:30:00', '2024-07-30T14:45:30'), '.')&#x5B;0], ':')&#x5B;0])\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1108\" height=\"696\" src=\"https:\/\/blog.gilosoft.com\/wp-content\/uploads\/2024\/09\/screenshot-2024-09-19-at-10.58.08e280afam.png?w=1024\" alt=\"\" class=\"wp-image-144\" srcset=\"https:\/\/blog.gilosoft.com\/wp-content\/uploads\/2024\/09\/screenshot-2024-09-19-at-10.58.08e280afam.png 1108w, https:\/\/blog.gilosoft.com\/wp-content\/uploads\/2024\/09\/screenshot-2024-09-19-at-10.58.08e280afam-300x188.png 300w, https:\/\/blog.gilosoft.com\/wp-content\/uploads\/2024\/09\/screenshot-2024-09-19-at-10.58.08e280afam-1024x643.png 1024w, https:\/\/blog.gilosoft.com\/wp-content\/uploads\/2024\/09\/screenshot-2024-09-19-at-10.58.08e280afam-768x482.png 768w\" sizes=\"auto, (max-width: 1108px) 100vw, 1108px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Finding differences in dates can be a useful skill in different scenarios where one might need to know the years, months, or days between two different dates. Thankfully Power Automate has a simple solution using the dateDifference() expression. In this blog, we will go through how to create a simple flow that will use the [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":145,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[3,4,5,6,7],"class_list":["post-133","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-power-automate-text-functions","tag-excel","tag-power-automate","tag-power-platform","tag-powerautomate","tag-powerplatform"],"_links":{"self":[{"href":"https:\/\/blog.gilosoft.com\/index.php\/wp-json\/wp\/v2\/posts\/133","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.gilosoft.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.gilosoft.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.gilosoft.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.gilosoft.com\/index.php\/wp-json\/wp\/v2\/comments?post=133"}],"version-history":[{"count":2,"href":"https:\/\/blog.gilosoft.com\/index.php\/wp-json\/wp\/v2\/posts\/133\/revisions"}],"predecessor-version":[{"id":161,"href":"https:\/\/blog.gilosoft.com\/index.php\/wp-json\/wp\/v2\/posts\/133\/revisions\/161"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.gilosoft.com\/index.php\/wp-json\/wp\/v2\/media\/145"}],"wp:attachment":[{"href":"https:\/\/blog.gilosoft.com\/index.php\/wp-json\/wp\/v2\/media?parent=133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.gilosoft.com\/index.php\/wp-json\/wp\/v2\/categories?post=133"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.gilosoft.com\/index.php\/wp-json\/wp\/v2\/tags?post=133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}