{"id":35932,"date":"2023-09-07T16:07:09","date_gmt":"2023-09-07T10:37:09","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=35932"},"modified":"2025-07-21T12:33:14","modified_gmt":"2025-07-21T07:03:14","slug":"how-to-use-the-datedifference-function-in-power-automate","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2023\/09\/how-to-use-the-datedifference-function-in-power-automate\/","title":{"rendered":"How to use the dateDifference() function in Power Automate"},"content":{"rendered":"<p>Power Automate has recently introduced an innovative function aimed at calculating the difference between two dates. However, finding the difference between two dates in Power Automate was quite complex, and with the recent introduction of <strong>dateDifference()<\/strong> function, Microsoft has eased that out.<\/p>\n<p>In this blog, we will see how the process of calculating the difference between two dates has been simplified compared to the complex logic of using <strong>ticks()<\/strong> function.<\/p>\n<p><strong>Scenario:<\/strong><\/p>\n<p>Let\u2019s see the scenario of calculating the days remaining for a subscription to expire from today\u2019s date. In many organizations, it&#8217;s very important to remain aware of when various licenses are about to expire. The ability to accurately determine the remaining days until a license subscription concludes holds high importance.<\/p>\n<p>Traditionally, this task could be achieved using the <strong>ticks()<\/strong> function, which seemed complex compared to the <strong>dateDifference()<\/strong> function. By leveraging the <strong>dateDifference()<\/strong> function, individuals can effortlessly compute the exact number of days left until a license subscription reaches its termination date. I have created a power automate flow for the creation of <strong>Account<\/strong> entity records. Also, I have fields for <strong>Start Date<\/strong> and <strong>End Date<\/strong> of a License, and also a whole number field for <strong>Expiry days<\/strong> field to display the remaining days until the license expires.<\/p>\n<p>Below are the steps for the power automate flow.<\/p>\n<ul>\n<li>Creation of Account.<\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-35938\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/09\/1Power-Automate.jpeg\" alt=\"Power Automate\" width=\"719\" height=\"255\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/09\/1Power-Automate.jpeg 719w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/09\/1Power-Automate-300x106.jpeg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/09\/1Power-Automate-660x234.jpeg 660w\" sizes=\"(max-width: 719px) 100vw, 719px\" \/><\/p>\n<ul>\n<li>Add an action \u201cUpdate a row\u201d to show the remaining expiration days.<\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-35937\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/09\/2Power-Automate.jpeg\" alt=\"Power Automate\" width=\"728\" height=\"157\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/09\/2Power-Automate.jpeg 728w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/09\/2Power-Automate-300x65.jpeg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/09\/2Power-Automate-660x142.jpeg 660w\" sizes=\"(max-width: 728px) 100vw, 728px\" \/><\/p>\n<ul>\n<li>Adding the datedifference() function in the Expiry days field.<\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-35936\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/09\/3Power-Automate.jpeg\" alt=\"Power Automate\" width=\"948\" height=\"473\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/09\/3Power-Automate.jpeg 948w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/09\/3Power-Automate-300x150.jpeg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/09\/3Power-Automate-768x383.jpeg 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/09\/3Power-Automate-660x329.jpeg 660w\" sizes=\"(max-width: 948px) 100vw, 948px\" \/><\/p>\n<p><strong>Expression \u2013 <\/strong><\/p>\n<p>dateDifference(formatDateTime(utcNow(),\u2019yyyy-MM-dd\u2019), formatDateTime(triggerOutputs()?[\u2018body\/cr9a6_enddate\u2019],\u2019yyyy-MM-dd\u2019))<\/p>\n<p>Here is the output of the remaining days for the expiration of the license as per the current date, i.e., 25<sup>th<\/sup> August, 2023.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-35935\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/09\/4Power-Automate.jpeg\" alt=\"Power Automate\" width=\"750\" height=\"452\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/09\/4Power-Automate.jpeg 750w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/09\/4Power-Automate-300x181.jpeg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/09\/4Power-Automate-660x398.jpeg 660w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/p>\n<p>The output is in <strong>{days}.{hours}:{minutes}:{seconds}<\/strong> format.<\/p>\n<p>Now if we want to show the difference only in days, we can use the <strong>split()<\/strong> function to get only days, as can be seen below.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-35934\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/09\/5Power-Automate.jpeg\" alt=\"Power Automate\" width=\"930\" height=\"480\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/09\/5Power-Automate.jpeg 930w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/09\/5Power-Automate-300x155.jpeg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/09\/5Power-Automate-768x396.jpeg 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/09\/5Power-Automate-660x341.jpeg 660w\" sizes=\"(max-width: 930px) 100vw, 930px\" \/><\/p>\n<p><strong>Expression:<\/strong> split(dateDifference(formatDateTime(utcNow(),&#8217;yyyy-MM-dd&#8217;),formatDateTime(triggerOutputs()?[&#8216;body\/cr9a6_enddate&#8217;],&#8217;yyyy-MM-dd&#8217;)),&#8217;.&#8217;)[0]\n<p>Here we get the only days remaining for the expiration of the license by extracting the hours, mins, secs.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-35933\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/09\/6Power-Automate.jpeg\" alt=\"Power Automate\" width=\"716\" height=\"492\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/09\/6Power-Automate.jpeg 716w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/09\/6Power-Automate-300x206.jpeg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/09\/6Power-Automate-660x454.jpeg 660w\" sizes=\"(max-width: 716px) 100vw, 716px\" \/><\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>In this blog, we explored the <strong>dateDifference()<\/strong> function and saw how it simplifies the complex logic for calculating the difference between the two dates.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Power Automate has recently introduced an innovative function aimed at calculating the difference between two dates. However, finding the difference between two dates in Power Automate was quite complex, and with the recent introduction of dateDifference() function, Microsoft has eased that out. In this blog, we will see how the process of calculating the difference\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2023\/09\/how-to-use-the-datedifference-function-in-power-automate\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":11,"featured_media":0,"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":[1985],"tags":[1975,3189],"class_list":["post-35932","post","type-post","status-publish","format-standard","hentry","category-power-automate","tag-power-automate","tag-power-automate-datedifference"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/35932","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\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=35932"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/35932\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=35932"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=35932"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=35932"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}