xref: /trunk/main/helpcontent2/source/text/scalc/01/func_datedif.xhp (revision 195598447694ec8542914a9b51ae9942e8ebacd9)
1<?xml version="1.0" encoding="UTF-8"?>
2
3<!--***********************************************************
4 *
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements.  See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership.  The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License.  You may obtain a copy of the License at
12 *
13 *   http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied.  See the License for the
19 * specific language governing permissions and limitations
20 * under the License.
21 *
22 ***********************************************************-->
23
24<helpdocument version="1.0">
25<meta>
26<topic id="textscalc01func_datedifxml" indexer="include" status="PUBLISH">
27<title id="tit" xml-lang="en-US">DATEDIF</title>
28<filename>/text/scalc/01/func_datedif.xhp</filename>
29</topic>
30</meta>
31<body>
32<bookmark xml-lang="en-US" branch="index" id="bm_id3155511">
33<bookmark_value>DATEDIF function</bookmark_value>
34<bookmark_value>date difference</bookmark_value>
35</bookmark>
36<bookmark xml-lang="en-US" branch="hid/SC_HID_FUNC_DATEDIF" id="bm_id3155512" localize="false"/>
37<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>
38</variable></paragraph>
39<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>
40<paragraph role="heading" id="hd_id3155514" xml-lang="en-US" level="3" l10n="U">Syntax</paragraph>
41<paragraph role="code" id="par_id3155515" xml-lang="en-US" l10n="U">DATEDIF(StartDate; EndDate; Format)</paragraph>
42<paragraph role="paragraph" id="par_id3155516" xml-lang="en-US" l10n="U"><emph>StartDate</emph> is the start date of the interval.</paragraph>
43<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>
44<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>
45<table id="tbl_id3155519">
46<tablerow>
47<tablecell>
48<paragraph role="tablehead" id="par_id3155520" xml-lang="en-US" l10n="U">Format</paragraph>
49</tablecell>
50<tablecell>
51<paragraph role="tablehead" id="par_id3155521" xml-lang="en-US" l10n="U">Meaning</paragraph>
52</tablecell>
53</tablerow>
54<tablerow>
55<tablecell>
56<paragraph role="tablecontent" id="par_id3155522" xml-lang="en-US" l10n="U">"d"</paragraph>
57</tablecell>
58<tablecell>
59<paragraph role="tablecontent" id="par_id3155523" xml-lang="en-US" l10n="U">Number of days between the dates.</paragraph>
60</tablecell>
61</tablerow>
62<tablerow>
63<tablecell>
64<paragraph role="tablecontent" id="par_id3155524" xml-lang="en-US" l10n="U">"m"</paragraph>
65</tablecell>
66<tablecell>
67<paragraph role="tablecontent" id="par_id3155525" xml-lang="en-US" l10n="U">Number of complete calendar months between the dates.</paragraph>
68</tablecell>
69</tablerow>
70<tablerow>
71<tablecell>
72<paragraph role="tablecontent" id="par_id3155526" xml-lang="en-US" l10n="U">"y"</paragraph>
73</tablecell>
74<tablecell>
75<paragraph role="tablecontent" id="par_id3155527" xml-lang="en-US" l10n="U">Number of complete calendar years between the dates.</paragraph>
76</tablecell>
77</tablerow>
78<tablerow>
79<tablecell>
80<paragraph role="tablecontent" id="par_id3155528" xml-lang="en-US" l10n="U">"md"</paragraph>
81</tablecell>
82<tablecell>
83<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>
84</tablecell>
85</tablerow>
86<tablerow>
87<tablecell>
88<paragraph role="tablecontent" id="par_id3155530" xml-lang="en-US" l10n="U">"ym"</paragraph>
89</tablecell>
90<tablecell>
91<paragraph role="tablecontent" id="par_id3155531" xml-lang="en-US" l10n="U">Months, ignoring years.</paragraph>
92</tablecell>
93</tablerow>
94<tablerow>
95<tablecell>
96<paragraph role="tablecontent" id="par_id3155532" xml-lang="en-US" l10n="U">"yd"</paragraph>
97</tablecell>
98<tablecell>
99<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>
100</tablecell>
101</tablerow>
102</table>
103<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>
104<paragraph role="heading" id="hd_id3155535" xml-lang="en-US" level="3" l10n="U">Examples</paragraph>
105<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>
106<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>
107</body>
108</helpdocument>
109