1<?xml version="1.0" encoding="UTF-8"?> 2 3 4<!--*********************************************************** 5 * 6 * Licensed to the Apache Software Foundation (ASF) under one 7 * or more contributor license agreements. See the NOTICE file 8 * distributed with this work for additional information 9 * regarding copyright ownership. The ASF licenses this file 10 * to you under the Apache License, Version 2.0 (the 11 * "License"); you may not use this file except in compliance 12 * with the License. You may obtain a copy of the License at 13 * 14 * http://www.apache.org/licenses/LICENSE-2.0 15 * 16 * Unless required by applicable law or agreed to in writing, 17 * software distributed under the License is distributed on an 18 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 19 * KIND, either express or implied. See the License for the 20 * specific language governing permissions and limitations 21 * under the License. 22 * 23 ***********************************************************--> 24 25 26 27<helpdocument version="1.0"> 28<meta> 29<topic id="textsbasicshared03030120xhp" indexer="include" status="PUBLISH"> 30<title id="tit" xml-lang="en-US">DateDiff Function [Runtime]</title> 31<filename>/text/sbasic/shared/03030120.xhp</filename> 32</topic> 33<history> 34<created date="2005-04-25T13:20:42">DateDiff</created> 35<lastedited date="2005-04-26T10:55:34">checked</lastedited> 36</history> 37</meta> 38<body> 39<section id="datediff"> 40<bookmark xml-lang="en-US" branch="index" id="bm_id6134830"><bookmark_value>DateDiff function</bookmark_value> 41</bookmark> 42<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> 43<paragraph role="paragraph" id="par_idN10546" xml-lang="en-US" l10n="NEW">Returns the number of date intervals between two given date values.</paragraph> 44</section> 45<paragraph role="heading" id="par_idN10549" xml-lang="en-US" level="2" l10n="NEW">Syntax:</paragraph> 46<paragraph role="paragraph" id="par_idN10648" xml-lang="en-US" l10n="NEW">DateDiff (Add, Date1, Date2 [, Week_start [, Year_start]])</paragraph> 47<paragraph role="heading" id="par_idN1064B" xml-lang="en-US" level="2" l10n="NEW">Return value:</paragraph> 48<paragraph role="paragraph" id="par_idN1064F" xml-lang="en-US" l10n="NEW">A number.</paragraph> 49<paragraph role="heading" id="par_idN10652" xml-lang="en-US" level="2" l10n="NEW">Parameters:</paragraph> 50<paragraph role="paragraph" id="par_idN10656" xml-lang="en-US" l10n="NEW"> 51<emph>Add</emph> - A string expression from the following table, specifying the date interval.</paragraph> 52<embed href="text/sbasic/shared/03030110.xhp#datetable"/> 53<paragraph role="paragraph" id="par_idN10664" xml-lang="en-US" l10n="NEW"> 54<emph>Date1, Date2</emph> - The two date values to be compared.</paragraph> 55<section id="weekyear"> 56<paragraph role="paragraph" id="par_idN1066A" xml-lang="en-US" l10n="NEW"> 57<emph>Week_start</emph> - An optional parameter that specifies the starting day of a week. </paragraph> 58<table id="tbl_id8356883"> 59<tablerow> 60<tablecell colspan="" rowspan=""> 61<paragraph role="tablehead" id="par_idN1067A" xml-lang="en-US" l10n="NEW">Week_start value</paragraph> 62</tablecell> 63<tablecell colspan="" rowspan=""> 64<paragraph role="tablehead" id="par_idN10680" xml-lang="en-US" l10n="NEW">Explanation</paragraph> 65</tablecell> 66</tablerow> 67<tablerow> 68<tablecell colspan="" rowspan=""> 69<paragraph role="tablecontent" id="par_idN10687" xml-lang="en-US" l10n="NEW">0</paragraph> 70</tablecell> 71<tablecell colspan="" rowspan=""> 72<paragraph role="tablecontent" id="par_idN1068D" xml-lang="en-US" l10n="NEW">Use system default value</paragraph> 73</tablecell> 74</tablerow> 75<tablerow> 76<tablecell colspan="" rowspan=""> 77<paragraph role="tablecontent" id="par_idN10694" xml-lang="en-US" l10n="NEW">1</paragraph> 78</tablecell> 79<tablecell colspan="" rowspan=""> 80<paragraph role="tablecontent" id="par_idN1069A" xml-lang="en-US" l10n="NEW">Sunday (default)</paragraph> 81</tablecell> 82</tablerow> 83<tablerow> 84<tablecell colspan="" rowspan=""> 85<paragraph role="tablecontent" id="par_idN106A1" xml-lang="en-US" l10n="NEW">2</paragraph> 86</tablecell> 87<tablecell colspan="" rowspan=""> 88<paragraph role="tablecontent" id="par_idN106A7" xml-lang="en-US" l10n="NEW">Monday</paragraph> 89</tablecell> 90</tablerow> 91<tablerow> 92<tablecell colspan="" rowspan=""> 93<paragraph role="tablecontent" id="par_idN106AE" xml-lang="en-US" l10n="NEW">3</paragraph> 94</tablecell> 95<tablecell colspan="" rowspan=""> 96<paragraph role="tablecontent" id="par_idN106B4" xml-lang="en-US" l10n="NEW">Tuesday</paragraph> 97</tablecell> 98</tablerow> 99<tablerow> 100<tablecell colspan="" rowspan=""> 101<paragraph role="tablecontent" id="par_idN106BB" xml-lang="en-US" l10n="NEW">4</paragraph> 102</tablecell> 103<tablecell colspan="" rowspan=""> 104<paragraph role="tablecontent" id="par_idN106C1" xml-lang="en-US" l10n="NEW">Wednesday</paragraph> 105</tablecell> 106</tablerow> 107<tablerow> 108<tablecell colspan="" rowspan=""> 109<paragraph role="tablecontent" id="par_idN106C8" xml-lang="en-US" l10n="NEW">5</paragraph> 110</tablecell> 111<tablecell colspan="" rowspan=""> 112<paragraph role="tablecontent" id="par_idN106CE" xml-lang="en-US" l10n="NEW">Thursday</paragraph> 113</tablecell> 114</tablerow> 115<tablerow> 116<tablecell colspan="" rowspan=""> 117<paragraph role="tablecontent" id="par_idN106D5" xml-lang="en-US" l10n="NEW">6</paragraph> 118</tablecell> 119<tablecell colspan="" rowspan=""> 120<paragraph role="tablecontent" id="par_idN106DB" xml-lang="en-US" l10n="NEW">Friday</paragraph> 121</tablecell> 122</tablerow> 123<tablerow> 124<tablecell colspan="" rowspan=""> 125<paragraph role="tablecontent" id="par_idN106E2" xml-lang="en-US" l10n="NEW">7</paragraph> 126</tablecell> 127<tablecell colspan="" rowspan=""> 128<paragraph role="tablecontent" id="par_idN106E8" xml-lang="en-US" l10n="NEW">Saturday</paragraph> 129</tablecell> 130</tablerow> 131</table> 132 133<paragraph role="paragraph" id="par_idN106EB" xml-lang="en-US" l10n="NEW"> 134<emph>Year_start</emph> - An optional parameter that specifies the starting week of a year. </paragraph> 135<table id="tbl_id1173436"> 136<tablerow> 137<tablecell colspan="" rowspan=""> 138<paragraph role="tablehead" id="par_idN106FB" xml-lang="en-US" l10n="NEW">Year_start value</paragraph> 139</tablecell> 140<tablecell colspan="" rowspan=""> 141<paragraph role="tablehead" id="par_idN10701" xml-lang="en-US" l10n="NEW">Explanation</paragraph> 142</tablecell> 143</tablerow> 144<tablerow> 145<tablecell colspan="" rowspan=""> 146<paragraph role="tablecontent" id="par_idN10708" xml-lang="en-US" l10n="NEW">0</paragraph> 147</tablecell> 148<tablecell colspan="" rowspan=""> 149<paragraph role="tablecontent" id="par_idN1070E" xml-lang="en-US" l10n="NEW">Use system default value</paragraph> 150</tablecell> 151</tablerow> 152<tablerow> 153<tablecell colspan="" rowspan=""> 154<paragraph role="tablecontent" id="par_idN10715" xml-lang="en-US" l10n="NEW">1</paragraph> 155</tablecell> 156<tablecell colspan="" rowspan=""> 157<paragraph role="tablecontent" id="par_idN1071B" xml-lang="en-US" l10n="NEW">Week 1 is the week with January, 1st (default)</paragraph> 158</tablecell> 159</tablerow> 160<tablerow> 161<tablecell colspan="" rowspan=""> 162<paragraph role="tablecontent" id="par_idN10722" xml-lang="en-US" l10n="NEW">2</paragraph> 163</tablecell> 164<tablecell colspan="" rowspan=""> 165<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> 166</tablecell> 167</tablerow> 168<tablerow> 169<tablecell colspan="" rowspan=""> 170<paragraph role="tablecontent" id="par_idN1072F" xml-lang="en-US" l10n="NEW">3</paragraph> 171</tablecell> 172<tablecell colspan="" rowspan=""> 173<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> 174</tablecell> 175</tablerow> 176</table> 177 178</section> 179<paragraph role="heading" id="par_idN10738" xml-lang="en-US" level="2" l10n="NEW">Example:</paragraph> 180<paragraph role="code" id="par_idN1073C" xml-lang="en-US" l10n="NEW">Sub example_datediff</paragraph> 181<paragraph role="code" id="par_idN1073F" xml-lang="en-US" l10n="NEW">msgbox DateDiff("d", "1/1/2005", "12/31/2005")</paragraph> 182<paragraph role="code" id="par_idN10742" xml-lang="en-US" l10n="NEW">End Sub</paragraph> 183</body> 184</helpdocument> 185