-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdate-diff-func.html
More file actions
73 lines (71 loc) · 3.39 KB
/
date-diff-func.html
File metadata and controls
73 lines (71 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>DATEDIFF Function - SQL Notebook</title>
<link rel="stylesheet" href="sqlnotebook.css">
</head>
<body>
<header>
<table class="nav">
<tr>
<td>
<a href="index.html"><img src="art/SqlNotebookIcon.png" alt="SQL Notebook (logo)" style="width: 58px; height: 58px; float: left; margin-right: 20px;"></a>
</td>
<td>
<a href="index.html" id="title">SQL Notebook</a><br>
<nav>
<ul class="nav">
<li><a href="https://github.com/brianluft/sqlnotebook/releases">Download</a></li>
<li><a href="doc.html"><span id="header-doc-long">Documentation</span><span id="header-doc-short">Docs</span></a></li>
<li><a href="https://github.com/brianluft/sqlnotebook">GitHub</a></li>
</ul>
</nav>
</td>
</tr>
</table>
<hr style="margin-top: 15px; margin-bottom: 15px;">
</header>
<article><div id="article">
<h1><code>DATEDIFF</code> Function</h1>
<p>Returns the number of calendar or clock boundaries crossed between two dates. A calendar boundary is a transition
from one day to the next, from one month to the next, etc. A clock boundary is a transition from one hour of the day
to the next, one minute of the day to the next, etc.</p>
<h2>Syntax</h2><code>DATEDIFF(<i>date-part</i>, <i>start-date</i>, <i>end-date</i>)</code><br>
<h2>Parameters</h2>
<ul class="args">
<li>
<i>date-part</i>: text<br>
One of the following predefined strings. Each <i>date-part</i> has abbreviated aliases that can be used in place
of the longer names without affecting the behavior.
<ul class="enum">
<li><code>year</code>, <code>yy</code>, <code>yyyy</code></li>
<li><code>quarter</code>, <code>qq</code>, <code>q</code></li>
<li><code>month</code>, <code>mm</code>, <code>m</code></li>
<li><code>dayofyear</code>, <code>dy</code>, <code>y</code></li>
<li><code>day</code>, <code>dd</code>, <code>d</code></li>
<li><code>week</code>, <code>wk</code>, <code>ww</code></li>
<li><code>weekday</code>, <code>dw</code></li>
<li><code>hour</code>, <code>hh</code></li>
<li><code>minute</code>, <code>mi</code>, <code>n</code></li>
<li><code>second</code>, <code>ss</code>, <code>s</code></li>
<li><code>millisecond</code>, <code>ms</code></li>
</ul>
</li>
<li><i>start-date</i>: text<br>
A text value that can be parsed into a date/time.<br></li>
<li><i>end-date</i>: text<br>
A text value that can be parsed into a date/time.<br></li>
</ul>
<h2>Return Value</h2>An integer representing the number of the specified <i>date-part</i> boundaries that are crossed
between <i>start-date</i> and <i>end-date</i>.<br>
<h2>Example</h2>
<pre><i>-- Prints "1" because the clock crosses midnight once.</i><br>PRINT DATEDIFF('day', '2016-03-04 03:53', '2016-03-05 11:53');<br><br><i>-- Prints "1" because the clock crosses the top of the hour once.</i><br>PRINT DATEDIFF('hh', '2016-01-01 03:59', '2016-01-01 04:01');<br><br><i>-- Prints "0" because the clock does not cross the top of the hour.</i><br>PRINT DATEDIFF('hh', '2016-01-01 03:50', '2016-01-01 03:52');<br></pre>
</div></article>
<footer><div id="footer">
<hr>
© 2016-2025 <a href="https://github.com/electroly">Brian Luft</a>
</div></footer>
</body>
</html>