1<?xml version="1.0" encoding="UTF-8"?>
2
3
4<!--***********************************************************************
5 *
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7 *
8 * Copyright 2000, 2010 Oracle and/or its affiliates.
9 *
10 * OpenOffice.org - a multi-platform office productivity suite
11 *
12 * This file is part of OpenOffice.org.
13 *
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
17 *
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
23 *
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org.  If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
28 *
29 ************************************************************************-->
30
31<helpdocument version="1.0">
32<meta>
33<topic id="textsbasicshared03030120xhp" indexer="include" status="PUBLISH">
34<title id="tit" xml-lang="en-US">DateDiff Function [Runtime]</title>
35<filename>/text/sbasic/shared/03030120.xhp</filename>
36</topic>
37<history>
38<created date="2005-04-25T13:20:42">DateDiff</created>
39<lastedited date="2005-04-26T10:55:34">checked</lastedited>
40</history>
41</meta>
42<body>
43<section id="datediff">
44<bookmark xml-lang="en-US" branch="index" id="bm_id6134830"><bookmark_value>DateDiff function</bookmark_value>
45</bookmark>
46<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>
47<paragraph role="paragraph" id="par_idN10546" xml-lang="en-US" l10n="NEW">Returns the number of date intervals between two given date values.</paragraph>
48</section>
49<paragraph role="heading" id="par_idN10549" xml-lang="en-US" level="2" l10n="NEW">Syntax:</paragraph>
50<paragraph role="paragraph" id="par_idN10648" xml-lang="en-US" l10n="NEW">DateDiff (Add, Date1, Date2 [, Week_start [, Year_start]])</paragraph>
51<paragraph role="heading" id="par_idN1064B" xml-lang="en-US" level="2" l10n="NEW">Return value:</paragraph>
52<paragraph role="paragraph" id="par_idN1064F" xml-lang="en-US" l10n="NEW">A number.</paragraph>
53<paragraph role="heading" id="par_idN10652" xml-lang="en-US" level="2" l10n="NEW">Parameters:</paragraph>
54<paragraph role="paragraph" id="par_idN10656" xml-lang="en-US" l10n="NEW">
55<emph>Add</emph> - A string expression from the following table, specifying the date interval.</paragraph>
56<embed href="text/sbasic/shared/03030110.xhp#datetable"/>
57<paragraph role="paragraph" id="par_idN10664" xml-lang="en-US" l10n="NEW">
58<emph>Date1, Date2</emph> - The two date values to be compared.</paragraph>
59<section id="weekyear">
60<paragraph role="paragraph" id="par_idN1066A" xml-lang="en-US" l10n="NEW">
61<emph>Week_start</emph> - An optional parameter that specifies the starting day of a week. </paragraph>
62<table id="tbl_id8356883">
63<tablerow>
64<tablecell colspan="" rowspan="">
65<paragraph role="tablehead" id="par_idN1067A" xml-lang="en-US" l10n="NEW">Week_start value</paragraph>
66</tablecell>
67<tablecell colspan="" rowspan="">
68<paragraph role="tablehead" id="par_idN10680" xml-lang="en-US" l10n="NEW">Explanation</paragraph>
69</tablecell>
70</tablerow>
71<tablerow>
72<tablecell colspan="" rowspan="">
73<paragraph role="tablecontent" id="par_idN10687" xml-lang="en-US" l10n="NEW">0</paragraph>
74</tablecell>
75<tablecell colspan="" rowspan="">
76<paragraph role="tablecontent" id="par_idN1068D" xml-lang="en-US" l10n="NEW">Use system default value</paragraph>
77</tablecell>
78</tablerow>
79<tablerow>
80<tablecell colspan="" rowspan="">
81<paragraph role="tablecontent" id="par_idN10694" xml-lang="en-US" l10n="NEW">1</paragraph>
82</tablecell>
83<tablecell colspan="" rowspan="">
84<paragraph role="tablecontent" id="par_idN1069A" xml-lang="en-US" l10n="NEW">Sunday (default)</paragraph>
85</tablecell>
86</tablerow>
87<tablerow>
88<tablecell colspan="" rowspan="">
89<paragraph role="tablecontent" id="par_idN106A1" xml-lang="en-US" l10n="NEW">2</paragraph>
90</tablecell>
91<tablecell colspan="" rowspan="">
92<paragraph role="tablecontent" id="par_idN106A7" xml-lang="en-US" l10n="NEW">Monday</paragraph>
93</tablecell>
94</tablerow>
95<tablerow>
96<tablecell colspan="" rowspan="">
97<paragraph role="tablecontent" id="par_idN106AE" xml-lang="en-US" l10n="NEW">3</paragraph>
98</tablecell>
99<tablecell colspan="" rowspan="">
100<paragraph role="tablecontent" id="par_idN106B4" xml-lang="en-US" l10n="NEW">Tuesday</paragraph>
101</tablecell>
102</tablerow>
103<tablerow>
104<tablecell colspan="" rowspan="">
105<paragraph role="tablecontent" id="par_idN106BB" xml-lang="en-US" l10n="NEW">4</paragraph>
106</tablecell>
107<tablecell colspan="" rowspan="">
108<paragraph role="tablecontent" id="par_idN106C1" xml-lang="en-US" l10n="NEW">Wednesday</paragraph>
109</tablecell>
110</tablerow>
111<tablerow>
112<tablecell colspan="" rowspan="">
113<paragraph role="tablecontent" id="par_idN106C8" xml-lang="en-US" l10n="NEW">5</paragraph>
114</tablecell>
115<tablecell colspan="" rowspan="">
116<paragraph role="tablecontent" id="par_idN106CE" xml-lang="en-US" l10n="NEW">Thursday</paragraph>
117</tablecell>
118</tablerow>
119<tablerow>
120<tablecell colspan="" rowspan="">
121<paragraph role="tablecontent" id="par_idN106D5" xml-lang="en-US" l10n="NEW">6</paragraph>
122</tablecell>
123<tablecell colspan="" rowspan="">
124<paragraph role="tablecontent" id="par_idN106DB" xml-lang="en-US" l10n="NEW">Friday</paragraph>
125</tablecell>
126</tablerow>
127<tablerow>
128<tablecell colspan="" rowspan="">
129<paragraph role="tablecontent" id="par_idN106E2" xml-lang="en-US" l10n="NEW">7</paragraph>
130</tablecell>
131<tablecell colspan="" rowspan="">
132<paragraph role="tablecontent" id="par_idN106E8" xml-lang="en-US" l10n="NEW">Saturday</paragraph>
133</tablecell>
134</tablerow>
135</table>
136
137<paragraph role="paragraph" id="par_idN106EB" xml-lang="en-US" l10n="NEW">
138<emph>Year_start</emph> - An optional parameter that specifies the starting week of a year. </paragraph>
139<table id="tbl_id1173436">
140<tablerow>
141<tablecell colspan="" rowspan="">
142<paragraph role="tablehead" id="par_idN106FB" xml-lang="en-US" l10n="NEW">Year_start value</paragraph>
143</tablecell>
144<tablecell colspan="" rowspan="">
145<paragraph role="tablehead" id="par_idN10701" xml-lang="en-US" l10n="NEW">Explanation</paragraph>
146</tablecell>
147</tablerow>
148<tablerow>
149<tablecell colspan="" rowspan="">
150<paragraph role="tablecontent" id="par_idN10708" xml-lang="en-US" l10n="NEW">0</paragraph>
151</tablecell>
152<tablecell colspan="" rowspan="">
153<paragraph role="tablecontent" id="par_idN1070E" xml-lang="en-US" l10n="NEW">Use system default value</paragraph>
154</tablecell>
155</tablerow>
156<tablerow>
157<tablecell colspan="" rowspan="">
158<paragraph role="tablecontent" id="par_idN10715" xml-lang="en-US" l10n="NEW">1</paragraph>
159</tablecell>
160<tablecell colspan="" rowspan="">
161<paragraph role="tablecontent" id="par_idN1071B" xml-lang="en-US" l10n="NEW">Week 1 is the week with January, 1st (default)</paragraph>
162</tablecell>
163</tablerow>
164<tablerow>
165<tablecell colspan="" rowspan="">
166<paragraph role="tablecontent" id="par_idN10722" xml-lang="en-US" l10n="NEW">2</paragraph>
167</tablecell>
168<tablecell colspan="" rowspan="">
169<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>
170</tablecell>
171</tablerow>
172<tablerow>
173<tablecell colspan="" rowspan="">
174<paragraph role="tablecontent" id="par_idN1072F" xml-lang="en-US" l10n="NEW">3</paragraph>
175</tablecell>
176<tablecell colspan="" rowspan="">
177<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>
178</tablecell>
179</tablerow>
180</table>
181
182</section>
183<paragraph role="heading" id="par_idN10738" xml-lang="en-US" level="2" l10n="NEW">Example:</paragraph>
184<paragraph role="code" id="par_idN1073C" xml-lang="en-US" l10n="NEW">Sub example_datediff</paragraph>
185<paragraph role="code" id="par_idN1073F" xml-lang="en-US" l10n="NEW">msgbox DateDiff("d", "1/1/2005", "12/31/2005")</paragraph>
186<paragraph role="code" id="par_idN10742" xml-lang="en-US" l10n="NEW">End Sub</paragraph>
187</body>
188</helpdocument>
189