{"id":32698,"date":"2022-09-30T15:01:31","date_gmt":"2022-09-30T09:31:31","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=32698"},"modified":"2025-01-16T11:44:25","modified_gmt":"2025-01-16T06:14:25","slug":"how-to-add-and-subtract-date-using-subtractfromtime-and-addtotime-functions-within-power-automate","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2022\/09\/how-to-add-and-subtract-date-using-subtractfromtime-and-addtotime-functions-within-power-automate\/","title":{"rendered":"How to add and subtract date using subtractFromTime() and addToTime() functions within Power Automate"},"content":{"rendered":"<p>In this blog, let us see how we can add and subtract an \u2018x\u2019 time unit such as second, minute, hour, day, week, month, and year into and from the existing date.<\/p>\n<p><strong><u>Requirement:<\/u><\/strong><br \/>\nWe recently had a client requirement in which, the client wanted to calculate the next follow-up date for the current customer. This operation is performed when a new Customer (Account) is to be added to CRM and customer details are to be updated in the CRM.<\/p>\n<p><strong><u>Solution:<\/u><\/strong><br \/>\nTo achieve the above user requirement we designed a <a href=\"https:\/\/www.inogic.com\/services\/microsoft-power-platform\/microsoft-power-automate\/?utm_source=inogic-t-blog&amp;utm_medium=power-automate&amp;utm_campaign=itblog&amp;utm_id=power-automate\" target=\"_blank\" rel=\"noopener\">Power Automate<\/a> flow that triggers the creation and modification of an account. We used\u00a0the <strong>addToTime()<\/strong>\u00a0function for this. On firing this flow, the\u00a0<strong>CreatedOn<\/strong>\u00a0field of the account is read and the\u00a0<strong>addToTime()<\/strong>\u00a0function gets applied to it. The output value gets updated in the \u201cNext follow up\u201d file which is filled on the account form. Please find the below syntax for the function:<\/p>\n<p>Syntax:<\/p>\n<p>addToTime(DATE_TIME,INTERVAL,TIME_UNIT,OUTPUT_DATE_FORMAT)<\/p>\n<p>Where,<\/p>\n<ol>\n<li>DATE_TIME_VALUE: It states the Date Time value in which the time is to be added<\/li>\n<li>INTERVAL_TIME: It represents the numeric number that defines how many seconds, minutes, hours, days, weeks, months, and years are to be added to the date<\/li>\n<li>TIME_UNIT: This defines which time unit (second, minute, hour, day, week, month, year) needs to be added to the existing date time<\/li>\n<li>OUTPUT_DATE_FORMAT: It shows the string date format in which the output of the date is to be seen<\/li>\n<\/ol>\n<p>Example:<\/p>\n<p>Here, we can notice that one week is created on the field of Account entity and displayed on the account entity form:<\/p>\n<p><strong><em>addToTime(triggerOutputs()?[\u2018body\/createdon\u2019],1,\u2019Week\u2019,\u00a0\u2018dd-MM-yyyy\u2019)<\/em><\/strong><\/p>\n<p>Output:<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-32699\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2022\/09\/1Power-Automate-in.jpeg\" alt=\"\" width=\"1361\" height=\"655\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2022\/09\/1Power-Automate-in.jpeg 1361w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2022\/09\/1Power-Automate-in-300x144.jpeg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2022\/09\/1Power-Automate-in-1024x493.jpeg 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2022\/09\/1Power-Automate-in-768x370.jpeg 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2022\/09\/1Power-Automate-in-660x318.jpeg 660w\" sizes=\"(max-width: 1361px) 100vw, 1361px\" \/><\/p>\n<p>Also, we can subtract second, minute, hour, day, week, month, and year from the existing date-time using the following-<\/p>\n<p><strong><em>subtractFromTime(triggerOutputs()?[&#8216;body\/createdon&#8217;],1,&#8217;Week&#8217;,\u00a0&#8216;dd-MM-yyyy&#8217;)<\/em><\/strong><\/p>\n<p>On firing the Power Automate flow we get the following result-<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-32700\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2022\/09\/2Power-Automate-1.jpeg\" alt=\"\" width=\"1363\" height=\"657\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2022\/09\/2Power-Automate-1.jpeg 1363w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2022\/09\/2Power-Automate-1-300x145.jpeg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2022\/09\/2Power-Automate-1-1024x494.jpeg 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2022\/09\/2Power-Automate-1-768x370.jpeg 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2022\/09\/2Power-Automate-1-660x318.jpeg 660w\" sizes=\"(max-width: 1363px) 100vw, 1363px\" \/><\/p>\n<p>Conclusion:<\/p>\n<p>Thus, in this manner, using <strong><em>subtractFromTime()<\/em><\/strong> and <strong><em>addToTime<\/em><\/strong> we can add or subtract second, minute, hour, day, week, month, or year time intervals from the existing date.<\/p>\n<p><strong><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\"> <\/strong><strong>Accelerate Your Project Timeline with Our Dedicated Development Team! <\/strong><strong><\/div><\/div><\/strong><\/p>\n<p>Facing Dynamics 365 CRM or Power Platform resource constraints? Whether you need dedicated <a href=\"https:\/\/bit.ly\/3B9qyds\">FTE developers<\/a>, <a href=\"https:\/\/bit.ly\/3XAeBoM\">outsourced development<\/a>, or offshore development centre support, we&#8217;re here to propel your project forward. Leverage our Microsoft Technologies expertise to meet deadlines and surpass expectations. Reach out to us at <a href=\"mailto:crm@inogic.com\">crm@inogic.com<\/a> for project success.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog, let us see how we can add and subtract an \u2018x\u2019 time unit such as second, minute, hour, day, week, month, and year into and from the existing date. Requirement: We recently had a client requirement in which, the client wanted to calculate the next follow-up date for the current customer. This\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2022\/09\/how-to-add-and-subtract-date-using-subtractfromtime-and-addtotime-functions-within-power-automate\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"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":[38,44,1985,2361],"tags":[],"class_list":["post-32698","post","type-post","status-publish","format-standard","hentry","category-microsoft-powerapps","category-power-apps","category-power-automate","category-technical"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/32698","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=32698"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/32698\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=32698"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=32698"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=32698"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}