<?xml version="1.0" encoding="UTF-8"?>

<!--***********************************************************
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 *
 ***********************************************************-->

<helpdocument version="1.0">
<meta>
<topic id="textscalc01func_datedifxml" indexer="include" status="PUBLISH">
<title id="tit" xml-lang="en-US">DATEDIF</title>
<filename>/text/scalc/01/func_datedif.xhp</filename>
</topic>
</meta>
<body>
<bookmark xml-lang="en-US" branch="index" id="bm_id3155511">
<bookmark_value>DATEDIF function</bookmark_value>
<bookmark_value>date difference</bookmark_value>
</bookmark>
<bookmark xml-lang="en-US" branch="hid/SC_HID_FUNC_DATEDIF" id="bm_id3155512" localize="false"/>
<paragraph role="heading" id="hd_id3155510" xml-lang="en-US" level="2" l10n="U"><variable id="datedif"><link href="text/scalc/01/func_datedif.xhp">DATEDIF</link>
</variable></paragraph>
<paragraph role="paragraph" id="par_id3155513" xml-lang="en-US" l10n="U"><ahelp hid="HID_FUNC_DATEDIF">Returns the difference between two date values, in the units specified.</ahelp></paragraph>
<paragraph role="heading" id="hd_id3155514" xml-lang="en-US" level="3" l10n="U">Syntax</paragraph>
<paragraph role="code" id="par_id3155515" xml-lang="en-US" l10n="U">DATEDIF(StartDate; EndDate; Format)</paragraph>
<paragraph role="paragraph" id="par_id3155516" xml-lang="en-US" l10n="U"><emph>StartDate</emph> is the start date of the interval.</paragraph>
<paragraph role="paragraph" id="par_id3155517" xml-lang="en-US" l10n="U"><emph>EndDate</emph> is the end date of the interval. Time fractions are ignored.</paragraph>
<paragraph role="paragraph" id="par_id3155518" xml-lang="en-US" l10n="U"><emph>Format</emph> is a text value that specifies the unit of the result. Upper and lower case letters are equivalent.</paragraph>
<table id="tbl_id3155519">
<tablerow>
<tablecell>
<paragraph role="tablehead" id="par_id3155520" xml-lang="en-US" l10n="U">Format</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablehead" id="par_id3155521" xml-lang="en-US" l10n="U">Meaning</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph role="tablecontent" id="par_id3155522" xml-lang="en-US" l10n="U">"d"</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3155523" xml-lang="en-US" l10n="U">Number of days between the dates.</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph role="tablecontent" id="par_id3155524" xml-lang="en-US" l10n="U">"m"</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3155525" xml-lang="en-US" l10n="U">Number of complete calendar months between the dates.</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph role="tablecontent" id="par_id3155526" xml-lang="en-US" l10n="U">"y"</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3155527" xml-lang="en-US" l10n="U">Number of complete calendar years between the dates.</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph role="tablecontent" id="par_id3155528" xml-lang="en-US" l10n="U">"md"</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3155529" xml-lang="en-US" l10n="U">Days, ignoring months and years. As in Microsoft Excel, the days of the month before the month of <emph>EndDate</emph> are borrowed, so the result can be negative: from January 31 to March 1, 2024 it is -1.</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph role="tablecontent" id="par_id3155530" xml-lang="en-US" l10n="U">"ym"</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3155531" xml-lang="en-US" l10n="U">Months, ignoring years.</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph role="tablecontent" id="par_id3155532" xml-lang="en-US" l10n="U">"yd"</paragraph>
</tablecell>
<tablecell>
<paragraph role="tablecontent" id="par_id3155533" xml-lang="en-US" l10n="U">Days, ignoring years. As in Microsoft Excel, <emph>EndDate</emph> is moved into the year of <emph>StartDate</emph>, or into the next year if it would come before <emph>StartDate</emph>.</paragraph>
</tablecell>
</tablerow>
</table>
<paragraph role="paragraph" id="par_id3155534" xml-lang="en-US" l10n="U">If <emph>StartDate</emph> is later than <emph>EndDate</emph>, the result is an error.</paragraph>
<paragraph role="heading" id="hd_id3155535" xml-lang="en-US" level="3" l10n="U">Examples</paragraph>
<paragraph role="paragraph" id="par_id3155536" xml-lang="en-US" l10n="U"><item type="input">=DATEDIF("2024-01-01";"2024-12-31";"d")</item> returns 365.</paragraph>
<paragraph role="paragraph" id="par_id3155537" xml-lang="en-US" l10n="U"><item type="input">=DATEDIF("2024-01-01";"2025-01-01";"y")</item> returns 1.</paragraph>
</body>
</helpdocument>
