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="textsbasicshared03030120xhp" indexer="include" status="PUBLISH">
27<title id="tit" xml-lang="en-US">DateDiff Function [Runtime]</title>
28<filename>/text/sbasic/shared/03030120.xhp</filename>
29</topic>
30<comment>DateDiff</comment>
31</meta>
32<body>
33<section id="datediff">
34<bookmark xml-lang="en-US" branch="index" id="bm_id6134830">
35<bookmark_value>DateDiff function</bookmark_value>
36</bookmark>
37<paragraph role="heading" id="par_idN10542" xml-lang="en-US" level="1" l10n="NEW"><link href="text/sbasic/shared/03030120.xhp">DateDiff Function [Runtime]</link></paragraph>
38<paragraph role="paragraph" id="par_idN10546" xml-lang="en-US" l10n="NEW">Returns the number of date intervals between two given date values.</paragraph>
39</section>
40<paragraph role="heading" id="par_idN10549" xml-lang="en-US" level="2" l10n="NEW">Syntax:</paragraph>
41<paragraph role="paragraph" id="par_idN10648" xml-lang="en-US" l10n="NEW">DateDiff (Add, Date1, Date2 [, Week_start [, Year_start]])</paragraph>
42<paragraph role="heading" id="par_idN1064B" xml-lang="en-US" level="2" l10n="NEW">Return value:</paragraph>
43<paragraph role="paragraph" id="par_idN1064F" xml-lang="en-US" l10n="NEW">A number.</paragraph>
44<paragraph role="heading" id="par_idN10652" xml-lang="en-US" level="2" l10n="NEW">Parameters:</paragraph>
45<paragraph role="paragraph" id="par_idN10656" xml-lang="en-US" l10n="NEW">
46<emph>Add</emph> - A string expression from the following table, specifying the date interval.</paragraph>
47<embed href="text/sbasic/shared/03030110.xhp#datetable"/>
48<paragraph role="paragraph" id="par_idN10664" xml-lang="en-US" l10n="NEW">
49<emph>Date1, Date2</emph> - The two date values to be compared.</paragraph>
50<section id="weekyear">
51<paragraph role="paragraph" id="par_idN1066A" xml-lang="en-US" l10n="NEW">
52<emph>Week_start</emph> - An optional parameter that specifies the starting day of a week.</paragraph>
53<table id="tbl_id8356883">
54<tablerow>
55<tablecell colspan="" rowspan="">
56<paragraph role="tablehead" id="par_idN1067A" xml-lang="en-US" l10n="NEW">Week_start value</paragraph>
57</tablecell>
58<tablecell colspan="" rowspan="">
59<paragraph role="tablehead" id="par_idN10680" xml-lang="en-US" l10n="NEW">Explanation</paragraph>
60</tablecell>
61</tablerow>
62<tablerow>
63<tablecell colspan="" rowspan="">
64<paragraph role="tablecontent" id="par_idN10687" xml-lang="en-US" l10n="NEW">0</paragraph>
65</tablecell>
66<tablecell colspan="" rowspan="">
67<paragraph role="tablecontent" id="par_idN1068D" xml-lang="en-US" l10n="NEW">Use system default value</paragraph>
68</tablecell>
69</tablerow>
70<tablerow>
71<tablecell colspan="" rowspan="">
72<paragraph role="tablecontent" id="par_idN10694" xml-lang="en-US" l10n="NEW">1</paragraph>
73</tablecell>
74<tablecell colspan="" rowspan="">
75<paragraph role="tablecontent" id="par_idN1069A" xml-lang="en-US" l10n="NEW">Sunday (default)</paragraph>
76</tablecell>
77</tablerow>
78<tablerow>
79<tablecell colspan="" rowspan="">
80<paragraph role="tablecontent" id="par_idN106A1" xml-lang="en-US" l10n="NEW">2</paragraph>
81</tablecell>
82<tablecell colspan="" rowspan="">
83<paragraph role="tablecontent" id="par_idN106A7" xml-lang="en-US" l10n="NEW">Monday</paragraph>
84</tablecell>
85</tablerow>
86<tablerow>
87<tablecell colspan="" rowspan="">
88<paragraph role="tablecontent" id="par_idN106AE" xml-lang="en-US" l10n="NEW">3</paragraph>
89</tablecell>
90<tablecell colspan="" rowspan="">
91<paragraph role="tablecontent" id="par_idN106B4" xml-lang="en-US" l10n="NEW">Tuesday</paragraph>
92</tablecell>
93</tablerow>
94<tablerow>
95<tablecell colspan="" rowspan="">
96<paragraph role="tablecontent" id="par_idN106BB" xml-lang="en-US" l10n="NEW">4</paragraph>
97</tablecell>
98<tablecell colspan="" rowspan="">
99<paragraph role="tablecontent" id="par_idN106C1" xml-lang="en-US" l10n="NEW">Wednesday</paragraph>
100</tablecell>
101</tablerow>
102<tablerow>
103<tablecell colspan="" rowspan="">
104<paragraph role="tablecontent" id="par_idN106C8" xml-lang="en-US" l10n="NEW">5</paragraph>
105</tablecell>
106<tablecell colspan="" rowspan="">
107<paragraph role="tablecontent" id="par_idN106CE" xml-lang="en-US" l10n="NEW">Thursday</paragraph>
108</tablecell>
109</tablerow>
110<tablerow>
111<tablecell colspan="" rowspan="">
112<paragraph role="tablecontent" id="par_idN106D5" xml-lang="en-US" l10n="NEW">6</paragraph>
113</tablecell>
114<tablecell colspan="" rowspan="">
115<paragraph role="tablecontent" id="par_idN106DB" xml-lang="en-US" l10n="NEW">Friday</paragraph>
116</tablecell>
117</tablerow>
118<tablerow>
119<tablecell colspan="" rowspan="">
120<paragraph role="tablecontent" id="par_idN106E2" xml-lang="en-US" l10n="NEW">7</paragraph>
121</tablecell>
122<tablecell colspan="" rowspan="">
123<paragraph role="tablecontent" id="par_idN106E8" xml-lang="en-US" l10n="NEW">Saturday</paragraph>
124</tablecell>
125</tablerow>
126</table>
127<paragraph role="paragraph" id="par_idN106EB" xml-lang="en-US" l10n="NEW">
128<emph>Year_start</emph> - An optional parameter that specifies the starting week of a year.</paragraph>
129<table id="tbl_id1173436">
130<tablerow>
131<tablecell colspan="" rowspan="">
132<paragraph role="tablehead" id="par_idN106FB" xml-lang="en-US" l10n="NEW">Year_start value</paragraph>
133</tablecell>
134<tablecell colspan="" rowspan="">
135<paragraph role="tablehead" id="par_idN10701" xml-lang="en-US" l10n="NEW">Explanation</paragraph>
136</tablecell>
137</tablerow>
138<tablerow>
139<tablecell colspan="" rowspan="">
140<paragraph role="tablecontent" id="par_idN10708" xml-lang="en-US" l10n="NEW">0</paragraph>
141</tablecell>
142<tablecell colspan="" rowspan="">
143<paragraph role="tablecontent" id="par_idN1070E" xml-lang="en-US" l10n="NEW">Use system default value</paragraph>
144</tablecell>
145</tablerow>
146<tablerow>
147<tablecell colspan="" rowspan="">
148<paragraph role="tablecontent" id="par_idN10715" xml-lang="en-US" l10n="NEW">1</paragraph>
149</tablecell>
150<tablecell colspan="" rowspan="">
151<paragraph role="tablecontent" id="par_idN1071B" xml-lang="en-US" l10n="NEW">Week 1 is the week with January, 1st (default)</paragraph>
152</tablecell>
153</tablerow>
154<tablerow>
155<tablecell colspan="" rowspan="">
156<paragraph role="tablecontent" id="par_idN10722" xml-lang="en-US" l10n="NEW">2</paragraph>
157</tablecell>
158<tablecell colspan="" rowspan="">
159<paragraph role="tablecontent" id="par_idN10728" xml-lang="en-US" l10n="NEW">Week 1 is the first week containing four or more days of that year</paragraph>
160</tablecell>
161</tablerow>
162<tablerow>
163<tablecell colspan="" rowspan="">
164<paragraph role="tablecontent" id="par_idN1072F" xml-lang="en-US" l10n="NEW">3</paragraph>
165</tablecell>
166<tablecell colspan="" rowspan="">
167<paragraph role="tablecontent" id="par_idN10735" xml-lang="en-US" l10n="NEW">Week 1 is the first week containing only days of the new year</paragraph>
168</tablecell>
169</tablerow>
170</table>
171</section>
172<paragraph role="heading" id="par_idN10738" xml-lang="en-US" level="2" l10n="NEW">Example:</paragraph>
173<paragraph role="code" id="par_idN1073C" xml-lang="en-US" l10n="NEW">Sub example_datediff</paragraph>
174<paragraph role="code" id="par_idN1073F" xml-lang="en-US" l10n="NEW">msgbox DateDiff("d", "1/1/2005", "12/31/2005")</paragraph>
175<paragraph role="code" id="par_idN10742" xml-lang="en-US" l10n="NEW">End Sub</paragraph>
176</body>
177</helpdocument>
178