{"id":4338,"date":"2017-05-06T23:17:17","date_gmt":"2017-05-06T21:17:17","guid":{"rendered":"https:\/\/www.sheetgo.com\/?p=4338"},"modified":"2017-05-06T23:17:17","modified_gmt":"2017-05-06T21:17:17","slug":"formula-datedif-planilhas-google","status":"publish","type":"post","link":"https:\/\/www.sheetgo.com\/pt\/blog\/google-sheets-formulas\/datedif-formula-google-sheets\/","title":{"rendered":"Como usar a f\u00f3rmula DATEDIF no Planilhas Google"},"content":{"rendered":"<p>[et_pb_section fb_built=&#8221;1&#8243; admin_label=&#8221;section&#8221; module_class=&#8221;sheetgo-post&#8221; _builder_version=&#8221;4.16&#8243; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][et_pb_row admin_label=&#8221;row&#8221; _builder_version=&#8221;4.16&#8243; background_size=&#8221;initial&#8221; background_position=&#8221;top_left&#8221; background_repeat=&#8221;repeat&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;4.16&#8243; custom_padding=&#8221;|||&#8221; global_colors_info=&#8221;{}&#8221; custom_padding__hover=&#8221;|||&#8221; theme_builder_area=&#8221;post_content&#8221;][et_pb_text _builder_version=&#8221;4.16&#8243; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p>In Google Sheets, if we need to know how far two different dates are separated from each other, we can make use of the<span>\u00a0<\/span><a href=\"https:\/\/support.google.com\/docs\/answer\/6055612?hl=en\" target=\"_blank\" rel=\"noopener noreferrer\">DATEDIF<\/a><span>\u00a0<\/span>formula. It stands for \u201cDate Difference\u201d. Depending on the specified unit type, the output is in either number of days, months or years.<\/p>\n<h3>Syntax<\/h3>\n<p><span><strong>DATEDIF(start_date, end_date, unit)<\/strong><\/span><\/p>\n<ul>\n<li><span><strong>start_date<\/strong><\/span><span>\u00a0<\/span>\u2013 the date which the formula calculates the \u2018date difference\u2019 from. This input has to be date type data, which we can\u00a0ensure either by using<span>\u00a0<\/span><a href=\"https:\/\/www.sheetgo.com\/blog\/google-sheets-formulas\/date-formula-google-sheets\/\" target=\"_blank\" rel=\"noopener noreferrer\">DATE <\/a>type returning functions or by using references to the cells that have dates.<\/li>\n<li><span><strong>end_date<\/strong><\/span><span>\u00a0<\/span>\u2013\u00a0the date until\u00a0which the formula calculates the \u2018date difference\u2019 to. Just like the<span>\u00a0<\/span><span><strong>start_date<\/strong><\/span>, this too has to be date type data.<\/li>\n<li><span><strong>unit<\/strong><\/span><span>\u00a0<\/span>\u2013 this parameter indicates\u00a0the DATEDIF formula which among the following measurement means\u00a0the output should be displayed in.<\/li>\n<\/ul>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2021\/10\/DATEDIF-formula-1-1.png&#8221; alt=&#8221;DATEDIF formula 1&#8243; title_text=&#8221;DATEDIF formula 1&#8243; _builder_version=&#8221;4.16&#8243; _module_preset=&#8221;default&#8221; custom_margin=&#8221;||-2px|||&#8221; custom_padding=&#8221;||0px|||&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.16&#8243; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h3>Usage: DATEDIF Formula<\/h3>\n<p>Nothing makes our understanding of a concept better than a set of few examples. Please consider\u00a0the following\u00a0snapshot.<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2021\/10\/DATEDIF-formula-2.png&#8221; alt=&#8221;DATEDIF formula 2&#8243; title_text=&#8221;DATEDIF formula 2&#8243; _builder_version=&#8221;4.16&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.16&#8243; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p>Let\u2019s have a look at the first case (row # 2). The DATEDIF formula accepted two date cells references for its<span>\u00a0<\/span><span><strong>start_date<\/strong><\/span><span>\u00a0<\/span>and<span>\u00a0<\/span><span><strong>end_date<\/strong><\/span><span>\u00a0<\/span>parameters. And since its<span>\u00a0<\/span><span><strong>unit<\/strong><\/span>parameter is \u201cD\u201d, it should give us\u00a0the number of days between<span>\u00a0<\/span><span><strong>start_date<\/strong><\/span><span>\u00a0<\/span>and<span>\u00a0<\/span><span><strong>end_date<\/strong><\/span>. True to the definition, it returned 125 as output. To validate this let us do a simple count of days it takes to reach 06-May-2017 from 01-Jan-2017. Leaving alone 01-Jan-2017, it is 30 days in January, 28 days in February, 31 days in March, 30 days in April and 6 days in May. So put together, it is 125 days.<\/p>\n<p>Moving on to the second case, the input dates remain the same, albeit taken in the form of<span>\u00a0<\/span><a href=\"https:\/\/www.sheetgo.com\/blog\/google-sheets-formulas\/date-formula-google-sheets\/\" target=\"_blank\" rel=\"noopener noreferrer\">DATE<\/a><span>\u00a0<\/span>functions. The difference is with the<span>\u00a0<\/span><span><strong>unit<\/strong><\/span><span>\u00a0<\/span>parameter, which is \u201cM\u201d in this example. So, it is set out to give us the number of whole months that elapsed from 01-Jan-2017\u00a0to 06-May-2017. Validating this quickly, we\u2019ll notice that only the months Jan, Feb, Mar and Apr have elapsed completely. So the output should be 4, which the formula dutifully returned.<\/p>\n<p>For the third example, we used a different means of expressing a date for<span>\u00a0<\/span><span><strong>start_date<\/strong><\/span><span>\u00a0<\/span>parameter, which the formula is okay with. While the<span>\u00a0<\/span><span><strong>end_date<\/strong><\/span><span>\u00a0<\/span>parameter is a regular reference to a date cell. The<span>\u00a0<\/span><span><strong>unit<\/strong><\/span><span>\u00a0<\/span>is \u201cY\u201d, therefore the formula returns the number of whole years that have elapsed from 01-Jun-2001 to 06-May-2017.<\/p>\n<h5>Curious cases of \u201cMD\u201d, \u201cYM\u201d and \u201cYD\u201d\u2026<\/h5>\n<p>Moving further to the fourth case \u2013 you\u2019ll notice we\u2019ve used yet another valid form of date value for<span>\u00a0<\/span><span><strong>start_date<\/strong><\/span><span>\u00a0<\/span>parameter. Given the value \u201cMD\u201d for its unit parameter, it should give us the number of days having subtracted any number of whole months that have elapsed. So, the DATEDIF formula ignores days from\u00a0all the elapsed months starting from 01-Jun-2001 to 01-May-2017. How many days does it take from 01-May-2017 to 06-May-2017? 5 it is, and rightly so, as per the result in this example.<\/p>\n<p>\u201cYM\u201d unit in the fifth example ensures the output is in months after ignoring any whole years elapsed after<span>\u00a0<\/span><span><strong>start_date<\/strong><\/span><span>\u00a0<\/span>and before<span>\u00a0<\/span><span><strong>end_date<\/strong><\/span>. So the formula ignores all the whole years from 02-Feb-2002 till 02-Feb-2017. Therefore, 3 is the number of whole months that have elapsed after 02-Feb-2017 and before 31-May-2017.<\/p>\n<p>The sixth example uses the same<span>\u00a0<\/span><span><strong>start_date<\/strong><\/span><span>\u00a0<\/span>and<span>\u00a0<\/span><span><strong>end_date<\/strong><\/span><span>\u00a0<\/span>values as that of its fifth counterpart. Except, the unit here is \u201cYD\u201d. So it should give us the output in a number of days after not considering years elapsed between the specified dates.\u00a0So after ignoring all the years elapsed between 02-Feb-2002 to 02-Feb-2017, the number of days it takes to reach 02-Feb-2017 to 31-May-2017 is 119.<\/p>\n<p>[\/et_pb_text][\/et_pb_column][\/et_pb_row][\/et_pb_section]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Google Sheets, if we need to know how far two different dates are separated from each other, we can make use of the\u00a0DATEDIF\u00a0formula. It stands for \u201cDate Difference\u201d. Depending on the specified unit type, the output is in either number of days, months or years. Syntax DATEDIF(start_date, end_date, unit) start_date\u00a0\u2013 the date which the [&hellip;]<\/p>\n","protected":false},"author":40,"featured_media":4383,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_et_pb_use_builder":"on","_et_pb_old_content":"In Google Sheets, if we need to know how far two different dates are separated from each other, we can make use of the <a href=\"https:\/\/support.google.com\/docs\/answer\/6055612?hl=en\" target=\"_blank\" rel=\"noopener\">DATEDIF<\/a> formula. It stands for \"Date Difference\". Depending on the specified unit type, the output is in either number of days, months or years.\n<h3>Syntax<\/h3>\n<span style=\"font-size: 14pt;\"><strong><span style=\"font-family: 'courier new', courier, monospace;\">DATEDIF(start_date, end_date, unit)<\/span><\/strong><\/span>\n<ul>\n \t<li><span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\"><strong>start_date<\/strong><\/span> - the date which the formula calculates the 'date difference' from. This input has to be date type data, which we can&nbsp;ensure either by using <a href=\"https:\/\/www.sheetgo.com\/date-formula-google-sheets\/\" target=\"_blank\" rel=\"noopener\">DATE<\/a> type returning functions or by using references to the cells that have dates.<\/li>\n \t<li><span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\"><strong>end_date<\/strong><\/span> -&nbsp;the date until&nbsp;which the formula calculates the 'date difference' to. Just like the <span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\"><strong>start_date<\/strong><\/span>, this too has to be date type data.<\/li>\n \t<li><span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\"><strong>unit<\/strong><\/span> - this parameter indicates&nbsp;the DATEDIF formula which among the following measurement means&nbsp;the output should be displayed in.<\/li>\n<\/ul>\n<img class=\"aligncenter size-full wp-image-4360\" src=\"https:\/\/static.sheetgo.com\/wp-content\/uploads\/2017\/10\/frame-generic-2.png\" alt=\"DATEDIF Formula - Illustration 1\" width=\"445\" height=\"171\">\n<h3>Usage: DATEDIF Formula<\/h3>\nNothing makes our understanding of a concept better than a set of few examples. Please consider&nbsp;the following&nbsp;snapshot.\n\n<img class=\"aligncenter size-full wp-image-4370\" src=\"https:\/\/static.sheetgo.com\/wp-content\/uploads\/2017\/10\/frame-generic-3.png\" alt=\"DATEDIF Formula - Illustration 2\" width=\"663\" height=\"218\">\n\nLet's have a look at the first case (row # 2). The DATEDIF formula accepted two date cells references for its <span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\"><strong>start_date<\/strong><\/span> and <span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\"><strong>end_date<\/strong><\/span> parameters. And since its <span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\"><strong>unit<\/strong><\/span> parameter is \"D\", it should give us&nbsp;the number of days between <span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\"><strong>start_date<\/strong><\/span> and <span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\"><strong>end_date<\/strong><\/span>. True to the definition, it returned 125 as output. To validate this let us do a simple count of days it takes to reach 06-May-2017 from 01-Jan-2017. Leaving alone 01-Jan-2017, it is 30 days in January, 28 days in February, 31 days in March, 30 days in April and 6 days in May. So put together, it is 125 days.\n\nMoving on to the second case, the input dates remain the same, albeit taken in the form of DATE functions. The difference is with the <span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\"><strong>unit<\/strong><\/span> parameter, which is \"M\" in this example. So, it is set out to give us the number of whole months that elapsed from 01-Jan-2017&nbsp;to 06-May-2017. Validating this quickly, we'll notice that only the months Jan, Feb, Mar and Apr have elapsed completely. So the output should be 4, which the formula dutifully returned.\n\nFor the third example, we used a different means of expressing a date for <span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\"><strong>start_date<\/strong><\/span> parameter, which the formula is okay with. While the <span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\"><strong>end_date<\/strong><\/span> parameter is a regular reference to a date cell. The <span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\"><strong>unit<\/strong><\/span> is \"Y\", therefore the formula returns the number of whole years that have elapsed from 01-Jun-2001 to 06-May-2017.\n<h5>Curious cases of \"MD\", \"YM\" and \"YD\"...<\/h5>\nMoving further to the fourth case - you'll notice we've used yet another valid form of date value for <span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\"><strong>start_date<\/strong><\/span> parameter. Given the value \"MD\" for its unit parameter, it should give us the number of days having subtracted any number of whole months that have elapsed. So, the DATEDIF formula ignores days from&nbsp;all the elapsed months starting from 01-Jun-2001 to 01-May-2017. How many days does it take from 01-May-2017 to 06-May-2017? 5 it is, and rightly so, as per the result in this example.\n\n\"YM\" unit in the fifth example ensures the output is in months after ignoring any whole years elapsed after <span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\"><strong>start_date<\/strong><\/span> and before <span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\"><strong>end_date<\/strong><\/span>. So the formula ignores all the whole years from 02-Feb-2002 till 02-Feb-2017. Therefore, 3 is the number of whole months that have elapsed after 02-Feb-2017 and before 31-May-2017.\n\nThe sixth example uses the same <span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\"><strong>start_date<\/strong><\/span> and <span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\"><strong>end_date<\/strong><\/span> values as that of its fifth counterpart. Except, the unit here is \"YD\". So it should give us the output in a number of days after not considering years elapsed between the specified dates.&nbsp;So after ignoring all the years elapsed between 02-Feb-2002 to 02-Feb-2017, the number of days it takes to reach 02-Feb-2017 to 31-May-2017 is 119.\n\n&nbsp;","_et_gb_content_width":"","footnotes":""},"categories":[54],"tags":[39,28],"class_list":["post-4338","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-google-sheets-formulas","tag-connections-t","tag-spreadsheets"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.sheetgo.com\/pt\/wp-json\/wp\/v2\/posts\/4338","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sheetgo.com\/pt\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sheetgo.com\/pt\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sheetgo.com\/pt\/wp-json\/wp\/v2\/users\/40"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sheetgo.com\/pt\/wp-json\/wp\/v2\/comments?post=4338"}],"version-history":[{"count":0,"href":"https:\/\/www.sheetgo.com\/pt\/wp-json\/wp\/v2\/posts\/4338\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sheetgo.com\/pt\/wp-json\/wp\/v2\/media\/4383"}],"wp:attachment":[{"href":"https:\/\/www.sheetgo.com\/pt\/wp-json\/wp\/v2\/media?parent=4338"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sheetgo.com\/pt\/wp-json\/wp\/v2\/categories?post=4338"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sheetgo.com\/pt\/wp-json\/wp\/v2\/tags?post=4338"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}