{"id":812,"date":"2022-01-14T13:54:22","date_gmt":"2022-01-14T13:54:22","guid":{"rendered":"https:\/\/logicbuilder.integroscrm.com\/help\/?page_id=812"},"modified":"2022-08-03T15:16:17","modified_gmt":"2022-08-03T15:16:17","slug":"date-difference","status":"publish","type":"page","link":"https:\/\/logicbuilder.integroscrm.com\/help\/date-difference\/","title":{"rendered":"Date Difference"},"content":{"rendered":"\n<p><a name=\"abstract\"><\/a>Calculates the difference between two dates in specified units of time. It may be used to build&nbsp;evaluation&nbsp;criteria for <a href=\"https:\/\/logicbuilder.integroscrm.com\/help\/branch\/\">Branch<\/a> or as the value for <a href=\"https:\/\/logicbuilder.integroscrm.com\/help\/set-entity-attributes\/\">Set Entity Attributes<\/a>.<\/p>\n\n\n<div style=\"background-color: #ddeaff; border-left: 6px solid #0072b3; padding: 12px;\">\n<p>Keep in mind when dealing with Time that in Sugar interface dates are displayed in the current users&#8217; TimeZone. In Logic Builder dates are as values from the database &#8211; in UTC format.<\/p>\n<\/div>\n\n\n<p><strong>inputs:&nbsp;<\/strong><\/p>\n\n\n\n<p><span style=\"color:#64c6ca;\">date from<\/span> &#8211; input the first date or datetime to calculate the difference<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Required: yes<\/li><\/ul>\n\n\n\n<p><span style=\"color:#64c6ca;\">date to<\/span> &#8211; input the second date or datetime to calculate the difference<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Required: yes<\/li><\/ul>\n\n\n\n<p><span style=\"color:#6888c9;\">result units<\/span> &#8211;&nbsp;select the time unit (minutes, hours. days, weeks, months, quarters, or years), in which the difference is to be expressed.&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Required: yes<\/li><\/ul>\n\n\n\n<p><strong>outputs:&nbsp;<\/strong><\/p>\n\n\n\n<p><span style=\"color:#6888c9;\">result<\/span> &#8211; number of specified time units (minutes, hours. days, weeks, months, quarters, or years)&nbsp;between two given dates.&nbsp;The result is positive when the&nbsp;<em>date from<\/em>&nbsp;is after the&nbsp;<em>date to<\/em>. The result is negative when the&nbsp;<em>date from<\/em>&nbsp;is before the&nbsp;<em>date to<\/em>.<\/p>\n\n\n\n<p>Few examples of results of Date Diff operator:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>Date From<\/td><td>Date To<\/td><td>Units<\/td><td>Result<\/td><\/tr><tr><td>2021-11-27<\/td><td>2021-11-23<\/td><td>Hours<\/td><td>96<\/td><\/tr><tr><td>2021-11-27<\/td><td>2021-11-23<\/td><td>Days<\/td><td>4<\/td><\/tr><tr><td>2021-11-23 18:56:00 (UTC+2)<\/td><td>2021-11-27 11:45:23 (UTC +2)<\/td><td>Hours<\/td><td>-88<\/td><\/tr><tr><td>2021-11-23 18:56:00 (UTC +2)<\/td><td>2021-11-27 11:45:23 (UTC +2)<\/td><td>Days<\/td><td>-3<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n<div style=\"background-color: #ddeaff; border-left: 6px solid #0072b3; padding: 12px;\">\n<p>It is possible to calculate the difference between date and datetime or vise-versa. In this case date is treated as&nbsp;<em>date<\/em>&nbsp;<em>00:00:00<\/em>, e.g.<\/p>\n<table>\n<tbody>\n<tr>\n<td>Date from<\/td>\n<td>Date To<\/td>\n<td>Units<\/td>\n<td>Result<\/td>\n<\/tr>\n<tr>\n<td>2021-11-25<\/td>\n<td>2021-11-25 15:06:00 (UTC +2)<\/td>\n<td>Hour<\/td>\n<td>-13<\/td>\n<\/tr>\n<tr>\n<td>2021-11-25<\/td>\n<td>2021-11-25 15:06:00 (UTC +2)<\/td>\n<td>Day<\/td>\n<td>0<\/td>\n<\/tr>\n<tr>\n<td>2021-11-27<\/td>\n<td>2021-11-23 11:27:00 (UTC +2)<\/td>\n<td>Hour<\/td>\n<td>86<\/td>\n<\/tr>\n<tr>\n<td>2021-11-27<\/td>\n<td>2021-11-23 11:27:00 (UTC +2)<\/td>\n<td>Day<\/td>\n<td>3<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p><!-- \/wp:post-content --><\/p>\n<p><!-- \/wp:paragraph --><br>\n<!-- wp:image {\"id\":516,\"width\":804,\"height\":339,\"sizeSlug\":\"large\",\"linkDestination\":\"none\"} --><\/p>\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-64-65b5933aa58148e68271614225b0833b-1024x432.png\" alt=\"\" class=\"wp-image-516\" width=\"804\" height=\"339\" srcset=\"https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-64-65b5933aa58148e68271614225b0833b-1024x432.png 1024w, https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-64-65b5933aa58148e68271614225b0833b-300x126.png 300w, https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-64-65b5933aa58148e68271614225b0833b-768x324.png 768w, https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-64-65b5933aa58148e68271614225b0833b.png 1319w\" sizes=\"auto, (max-width: 804px) 100vw, 804px\" \/><\/figure>\n<p><!-- \/wp:image --><\/p><div style=\"text-align:left\" class=\"yasr-auto-insert-visitor\"><!--Yasr Visitor Votes Shortcode--><div id='yasr_visitor_votes_812' class='yasr-visitor-votes'><div class=\"yasr-custom-text-vv-before yasr-custom-text-vv-before-812\">Click to rate this post!<\/div><div id='yasr-vv-second-row-container-0979e48d694c1' \n                                        class='yasr-vv-second-row-container'><div id='yasr-visitor-votes-rater-0979e48d694c1'\n                                      class='yasr-rater-stars-vv'\n                                      data-rater-postid='812' \n                                      data-rating='0'\n                                      data-rater-starsize='24'\n                                      data-rater-readonly='false'\n                                      data-rater-nonce='60508256f2' \n                                      data-issingular='false'\n                                    ><\/div><div class=\"yasr-vv-stats-text-container\" id=\"yasr-vv-stats-text-container-0979e48d694c1\"><svg xmlns=\"https:\/\/www.w3.org\/2000\/svg\" width=\"20\" height=\"20\" \n                               class=\"yasr-dashicons-visitor-stats\"\n                               data-postid=\"812\" \n                               id=\"yasr-stats-dashicon-0979e48d694c1\">\n                            <path d=\"M18 18v-16h-4v16h4zM12 18v-11h-4v11h4zM6 18v-8h-4v8h4z\"><\/path>\n                          <\/svg><span id=\"yasr-vv-text-container-0979e48d694c1\" class=\"yasr-vv-text-container\">[Total: <span id=\"yasr-vv-votes-number-container-0979e48d694c1\">0<\/span>  Average: <span id=\"yasr-vv-average-container-0979e48d694c1\">0<\/span>]<\/span><\/div><div id='yasr-vv-loader-0979e48d694c1' class='yasr-vv-container-loader'><\/div><\/div><div id='yasr-vv-bottom-container-0979e48d694c1' class='yasr-vv-bottom-container'><\/div><\/div><!--End Yasr Visitor Votes Shortcode--><\/div>","protected":false},"excerpt":{"rendered":"<p>Calculates the difference between two dates in specified units of time. It may be used to build&nbsp;evaluation&nbsp;criteria for Branch or as the value for Set Entity Attributes. Keep in mind when dealing with Time that in Sugar interface dates are displayed in the current users&#8217; TimeZone. In Logic Builder dates are as values from the &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/logicbuilder.integroscrm.com\/help\/date-difference\/\"> <span class=\"screen-reader-text\">Date Difference<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"yasr_overall_rating":0,"yasr_post_is_review":"","yasr_auto_insert_disabled":"","yasr_review_type":"","footnotes":""},"tags":[],"class_list":["post-812","page","type-page","status-publish","hentry"],"yasr_visitor_votes":{"number_of_votes":0,"sum_votes":0,"stars_attributes":{"read_only":false,"span_bottom":false}},"_links":{"self":[{"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/pages\/812","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/comments?post=812"}],"version-history":[{"count":5,"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/pages\/812\/revisions"}],"predecessor-version":[{"id":2045,"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/pages\/812\/revisions\/2045"}],"wp:attachment":[{"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/media?parent=812"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/tags?post=812"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}