-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdate-trunc-func.html
More file actions
70 lines (68 loc) · 2.86 KB
/
date-trunc-func.html
File metadata and controls
70 lines (68 loc) · 2.86 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
<!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>DATE_TRUNC 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>DATE_TRUNC</code> Function</h1>
<p>Returns a new date by finding the nearest specified calendar or clock division prior to the specified source
date.</p>
<h2>Syntax<br></h2><tt>DATE_TRUNC(<i>date-part</i>, <i>date</i>)</tt><br>
<h2>Parameters</h2>
<ul class="args">
<li>
<i>date-part</i>: text<br>
One of the following predefined strings:
<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>date</i>: text<br>
A text value that can be parsed into a date/time.</li>
</ul>
<h2>Return Value<br></h2>A string like "2016-07-23 21:00:00.000 -04:00", calculated by finding the nearest specified
time division prior to the specified <i>date</i>.<br>
<h2>Example</h2>
<pre><i>-- Prints "2016-07-01 00:00:00.000".</i><br>PRINT DATE_TRUNC('month', '2016-07-23 12:23:00');<br><br><i>-- Prints "2015-08-02 00:00:00.000".</i>
PRINT DATE_TRUNC('week', '2015-08-03 12:41:25');<br><br><i>-- Prints "2015-02-03 12:00:00.000".</i><br>PRINT DATE_TRUNC('hh', '2015-02-03 12:41:25');<br></pre>
</div></article>
<footer><div id="footer">
<hr>
© 2016-2025 <a href="https://github.com/electroly">Brian Luft</a>
</div></footer>
</body>
</html>