drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tshi...@apache.org
Subject [19/51] [partial] drill-site git commit: Initial commit
Date Mon, 04 May 2015 19:26:51 GMT
http://git-wip-us.apache.org/repos/asf/drill-site/blob/c4de0f83/docs/date-time-functions-and-arithmetic/index.html
----------------------------------------------------------------------
diff --git a/docs/date-time-functions-and-arithmetic/index.html b/docs/date-time-functions-and-arithmetic/index.html
new file mode 100644
index 0000000..5e2b05c
--- /dev/null
+++ b/docs/date-time-functions-and-arithmetic/index.html
@@ -0,0 +1,1302 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+
+<meta charset="UTF-8">
+<meta name=viewport content="width=device-width, initial-scale=1">
+
+
+<title>Date/Time Functions and Arithmetic - Apache Drill</title>
+
+<link href="/css/syntax.css" rel="stylesheet" type="text/css">
+<link href="/css/style.css" rel="stylesheet" type="text/css">
+<link href="/css/arrows.css" rel="stylesheet" type="text/css">
+<link href="/css/breadcrumbs.css" rel="stylesheet" type="text/css">
+<link href="/css/code.css" rel="stylesheet" type="text/css">
+<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
+<link href="/css/responsive.css" rel="stylesheet" type="text/css">
+
+<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
+<link rel="icon" href="/favicon.ico" type="image/x-icon">
+
+<script language="javascript" type="text/javascript" src="/js/lib/jquery-1.11.1.min.js"></script>
+<script language="javascript" type="text/javascript" src="/js/lib/jquery.easing.1.3.js"></script>
+<script language="javascript" type="text/javascript" src="/js/modernizr.custom.js"></script>
+<script language="javascript" type="text/javascript" src="/js/script.js"></script>
+<script language="javascript" type="text/javascript" src="/js/drill.js"></script>
+
+
+</head>
+
+<body onResize="resized();">
+  <div class="page-wrap">
+    <div class="bui"></div>
+
+<div id="menu" class="mw">
+<ul>
+  <li class='toc-categories'>
+  <a class="expand-toc-icon" href="javascript:void(0);"><i class="fa fa-bars"></i></a>
+  </li>
+  <li class="logo"><a href="/"></a></li>
+  <li class='expand-menu'>
+  <a href="javascript:void(0);"><span class='menu-text'>Menu</span><span class='expand-icon'><i class="fa fa-bars"></i></span></a>
+  </li>
+  <li class='clear-float'></li>
+  <li class="documentation-menu">
+    <a href="/docs/">Documentation</a>
+    <ul>
+      
+        <li><a href="/docs/getting-started/">Getting Started</a></li>
+      
+        <li><a href="/docs/architecture/">Architecture</a></li>
+      
+        <li><a href="/docs/tutorials/">Tutorials</a></li>
+      
+        <li><a href="/docs/install-drill/">Install Drill</a></li>
+      
+        <li><a href="/docs/connect-a-data-source/">Connect a Data Source</a></li>
+      
+        <li><a href="/docs/odbc-jdbc-interfaces/">ODBC/JDBC Interfaces</a></li>
+      
+        <li><a href="/docs/query-data/">Query Data</a></li>
+      
+        <li><a href="/docs/sql-reference/">SQL Reference</a></li>
+      
+        <li><a href="/docs/data-sources-and-file-formats/">Data Sources and File Formats</a></li>
+      
+        <li><a href="/docs/develop-custom-functions/">Develop Custom Functions</a></li>
+      
+        <li><a href="/docs/manage-drill/">Manage Drill</a></li>
+      
+        <li><a href="/docs/developer-information/">Developer Information</a></li>
+      
+        <li><a href="/docs/release-notes/">Release Notes</a></li>
+      
+        <li><a href="/docs/sample-datasets/">Sample Datasets</a></li>
+      
+        <li><a href="/docs/archived-pages/">Archived Pages</a></li>
+      
+        <li><a href="/docs/progress-reports/">Progress Reports</a></li>
+      
+        <li><a href="/docs/project-bylaws/">Project Bylaws</a></li>
+      
+    </ul>
+  </li>
+  <li class='nav'>
+    <a href="/community-resources/">Community</a>
+    <ul>
+      <li><a href="/team/">Team</a></li>
+      <li><a href="/mailinglists/">Mailing Lists</a></li>
+      <li><a href="/community-resources/">Community Resources</a></li>
+    </ul>
+  </li>
+  <li class='nav'><a href="/faq/">FAQ</a></li>
+  <li class='nav'><a href="/blog/">Blog</a></li>
+  <li id="twitter-menu-item"><a href="https://twitter.com/apachedrill" title="apachedrill on twitter" target="_blank"><img src="/images/twitter_32_26_white.png" alt="twitter logo" align="center"></a> </li>
+  <li class='search-bar'>
+    <form id="drill-search-form">
+      <input type="text" placeholder="Search Apache Drill" id="drill-search-term" />
+      <button type="submit">
+        <i class="fa fa-search"></i>
+      </button>
+    </form>
+  </li>
+  <li class="d">
+    <a href="/download/">
+      <i class="fa fa-cloud-download"></i> Download
+    </a>
+  </li>
+</ul>
+</div>
+
+      
+      
+
+
+
+
+<aside class="sidebar">
+  <div class="docsidebar">
+    <div class="docsidebarwrapper">
+      <ul style="display: block;">
+      
+        
+          <li class="toctree-l1"><a href="javascript: void(0);">Getting Started</a></li>
+          <ul style="display: none">
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/drill-introduction/">Drill Introduction</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/why-drill/">Why Drill</a></li>
+            
+          
+          </ul>
+        
+      
+        
+          <li class="toctree-l1"><a href="javascript: void(0);">Architecture</a></li>
+          <ul style="display: none">
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/architecture-introduction/">Architecture Introduction</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/core-modules/">Core Modules</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a href="javascript: void(0);">Architectural Highlights</a></li>
+              <ul style="display: none">
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/flexibility/">Flexibility</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/performance/">Performance</a></li>
+              
+            </ul>
+            
+          
+          </ul>
+        
+      
+        
+          <li class="toctree-l1"><a href="javascript: void(0);">Tutorials</a></li>
+          <ul style="display: none">
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/tutorials-introduction/">Tutorials Introduction</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/drill-in-10-minutes/">Drill in 10 Minutes</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/analyzing-the-yelp-academic-dataset/">Analyzing the Yelp Academic Dataset</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a href="javascript: void(0);">Learn Drill with the MapR Sandbox</a></li>
+              <ul style="display: none">
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/about-the-mapr-sandbox/">About the MapR Sandbox</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/installing-the-apache-drill-sandbox/">Installing the Apache Drill Sandbox</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/getting-to-know-the-drill-sandbox/">Getting to Know the Drill Sandbox</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/lession-1-learn-about-the-data-set/">Lession 1: Learn about the Data Set</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/lession-2-run-queries-with-ansi-sql/">Lession 2: Run Queries with ANSI SQL</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/lession-3-run-queries-on-complex-data-types/">Lession 3: Run Queries on Complex Data Types</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/summary/">Summary</a></li>
+              
+            </ul>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/analyzing-highly-dynamic-datasets/">Analyzing Highly Dynamic Datasets</a></li>
+            
+          
+          </ul>
+        
+      
+        
+          <li class="toctree-l1"><a href="javascript: void(0);">Install Drill</a></li>
+          <ul style="display: none">
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/install-drill-introduction/">Install Drill Introduction</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/deploying-drill-in-a-cluster/">Deploying Drill in a Cluster</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a href="javascript: void(0);">Installing Drill in Embedded Mode</a></li>
+              <ul style="display: none">
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/embedded-mode-prerequisites/">Embedded Mode Prerequisites</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/installing-drill-on-linux/">Installing Drill on Linux</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/installing-drill-on-mac-os-x/">Installing Drill on Mac OS X</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/installing-drill-on-windows/">Installing Drill on Windows</a></li>
+              
+            </ul>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/installing-drill-in-distributed-mode/">Installing Drill in Distributed Mode</a></li>
+            
+          
+          </ul>
+        
+      
+        
+          <li class="toctree-l1"><a href="javascript: void(0);">Connect a Data Source</a></li>
+          <ul style="display: none">
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/connect-a-data-source-introduction/">Connect a Data Source Introduction</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/storage-plugin-registration/">Storage Plugin Registration</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a href="javascript: void(0);">Storage Plugin Configuration</a></li>
+              <ul style="display: none">
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/plugin-configuration-introduction/">Plugin Configuration Introduction</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/workspaces/">Workspaces</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/file-system-storage-plugin/">File System Storage Plugin</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/hbase-storage-plugin/">HBase Storage Plugin</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/hive-storage-plugin/">Hive Storage Plugin</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/drill-default-input-format/">Drill Default Input Format</a></li>
+              
+            </ul>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/mongodb-plugin-for-apache-drill/">MongoDB Plugin for Apache Drill</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/mapr-db-format/">MapR-DB Format</a></li>
+            
+          
+          </ul>
+        
+      
+        
+          <li class="toctree-l1"><a href="javascript: void(0);">ODBC/JDBC Interfaces</a></li>
+          <ul style="display: none">
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/interfaces-introduction/">Interfaces Introduction</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/using-jdbc/">Using JDBC</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a href="javascript: void(0);">Using ODBC on Linux and Mac OS X</a></li>
+              <ul style="display: none">
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/odbc-on-linux-and-mac-introduction/">ODBC on Linux and Mac Introduction</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/installing-the-driver-on-linux/">Installing the Driver on Linux</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/installing-the-driver-on-mac-os-x/">Installing the Driver on Mac OS X</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/configuring-connections-on-linux-and-mac-os-x/">Configuring Connections on Linux and Mac OS X</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/driver-configuration-options/">Driver Configuration Options</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/using-a-connection-string/">Using a Connection String</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/advanced-properties/">Advanced Properties</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/testing-the-odbc-connection/">Testing the ODBC Connection</a></li>
+              
+            </ul>
+            
+          
+            
+              <li class="toctree-l2"><a href="javascript: void(0);">Using ODBC on Windows</a></li>
+              <ul style="display: none">
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/installing-the-driver-on-windows/">Installing the Driver on Windows</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/configuring-connections-on-windows/">Configuring Connections on Windows</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/connecting-to-odbc-data-sources/">Connecting to ODBC Data Sources</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/tableau-examples/">Tableau Examples</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/using-drill-explorer-on-windows/">Using Drill Explorer on Windows</a></li>
+              
+            </ul>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/using-microstrategy-analytics-with-drill/">Using MicroStrategy Analytics with Drill</a></li>
+            
+          
+          </ul>
+        
+      
+        
+          <li class="toctree-l1"><a href="javascript: void(0);">Query Data</a></li>
+          <ul style="display: none">
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/query-data-introduction/">Query Data Introduction</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a href="javascript: void(0);">Querying a File System</a></li>
+              <ul style="display: none">
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/querying-a-file-system-introduction/">Querying a File System Introduction</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/querying-json-files/">Querying JSON Files</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/querying-parquet-files/">Querying Parquet Files</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/querying-plain-text-files/">Querying Plain Text Files</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/querying-directories/">Querying Directories</a></li>
+              
+            </ul>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/querying-hbase/">Querying HBase</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a href="javascript: void(0);">Querying Complex Data</a></li>
+              <ul style="display: none">
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/querying-complex-data-introduction/">Querying Complex Data Introduction</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/sample-data-donuts/">Sample Data: Donuts</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/selecting-flat-data/">Selecting Flat Data</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/using-sql-functions-clauses-and-joins/">Using SQL Functions, Clauses, and Joins</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/selecting-nested-data-for-a-column/">Selecting Nested Data for a Column</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/selecting-multiple-columns-within-nested-data/">Selecting Multiple Columns Within Nested Data</a></li>
+              
+            </ul>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/querying-hive/">Querying Hive</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/querying-the-information-schema/">Querying the INFORMATION SCHEMA</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/querying-system-tables/">Querying System Tables</a></li>
+            
+          
+          </ul>
+        
+      
+        
+          <li class="toctree-l1 current_section "><a href="javascript: void(0);">SQL Reference</a></li>
+          <ul class="current_section">
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/sql-reference-introduction/">SQL Reference Introduction</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a href="javascript: void(0);">Data Types</a></li>
+              <ul style="display: none">
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/supported-data-types/">Supported Data Types</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/date-time-and-timestamp/">Date, Time, and Timestamp</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/handling-different-data-types/">Handling Different Data Types</a></li>
+              
+            </ul>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/lexical-structure/">Lexical Structure</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/operators/">Operators</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a href="javascript: void(0);">SQL Functions</a></li>
+              <ul style="">
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/about-sql-function-examples/">About SQL Function Examples</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/math-and-trig/">Math and Trig</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/data-type-conversion/">Data Type Conversion</a></li>
+              
+                <li class="toctree-l3 current"><a class="reference internal" href="/docs/date-time-functions-and-arithmetic/">Date/Time Functions and Arithmetic</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/string-manipulation/">String Manipulation</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/aggregate-and-aggregate-statistical/">Aggregate and Aggregate Statistical</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/functions-for-handling-nulls/">Functions for Handling Nulls</a></li>
+              
+            </ul>
+            
+          
+            
+              <li class="toctree-l2"><a href="javascript: void(0);">Nested Data Functions</a></li>
+              <ul style="display: none">
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/nested-data-limitations/">Nested Data Limitations</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/flatten/">FLATTEN</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/kvgen/">KVGEN</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/repeated-count/">REPEATED_COUNT</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/repeated-contains/">REPEATED_CONTAINS</a></li>
+              
+            </ul>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/query-directory-functions/">Query Directory Functions</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a href="javascript: void(0);">SQL Commands</a></li>
+              <ul style="display: none">
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/supported-sql-commands/">Supported SQL Commands</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/alter-session-command/">ALTER SESSION Command</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/alter-system-command/">ALTER SYSTEM Command</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/create-table-as-ctas-command/">CREATE TABLE AS (CTAS) command</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/create-view-command/">CREATE VIEW command</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/describe-command/">DESCRIBE Command</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/explain-commands/">EXPLAIN commands</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/select-statements/">SELECT Statements</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/show-databases-and-show-schemas-command/">SHOW DATABASES AND SHOW SCHEMAS Command</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/show-files-command/">SHOW FILES Command</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/show-tables-command/">SHOW TABLES Command</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/use-command/">USE Command</a></li>
+              
+            </ul>
+            
+          
+            
+              <li class="toctree-l2"><a href="javascript: void(0);">SQL Conditional Expressions</a></li>
+              <ul style="display: none">
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/case/">CASE</a></li>
+              
+            </ul>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/reserved-keywords/">Reserved Keywords</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/sql-extensions/">SQL Extensions</a></li>
+            
+          
+          </ul>
+        
+      
+        
+          <li class="toctree-l1"><a href="javascript: void(0);">Data Sources and File Formats</a></li>
+          <ul style="display: none">
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/data-sources-and-file-formats-introduction/">Data Sources and File Formats Introduction</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/hive-to-drill-data-type-mapping/">Hive-to-Drill Data Type Mapping</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/deploying-and-using-a-hive-udf/">Deploying and Using a Hive UDF</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/parquet-format/">Parquet Format</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/json-data-model/">JSON Data Model</a></li>
+            
+          
+          </ul>
+        
+      
+        
+          <li class="toctree-l1"><a href="javascript: void(0);">Develop Custom Functions</a></li>
+          <ul style="display: none">
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/develop-custom-functions-introduction/">Develop Custom Functions Introduction</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/develop-a-simple-function/">Develop a Simple Function</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/developing-an-aggregate-function/">Developing an Aggregate Function</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/adding-custom-functions-to-drill/">Adding Custom Functions to Drill</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/using-custom-functions-in-queries/">Using Custom Functions in Queries</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/custom-function-interfaces/">Custom Function Interfaces</a></li>
+            
+          
+          </ul>
+        
+      
+        
+          <li class="toctree-l1"><a href="javascript: void(0);">Manage Drill</a></li>
+          <ul style="display: none">
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/manage-drill-introduction/">Manage Drill Introduction</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/configuring-drill-in-a-dedicated-cluster/">Configuring Drill in a Dedicated Cluster</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a href="javascript: void(0);">Configuring a Multitenant Cluster</a></li>
+              <ul style="display: none">
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/configuring-a-multitenant-cluster-introduction/">Configuring a Multitenant Cluster Introduction</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/configuring-multitenant-resources/">Configuring Multitenant Resources</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/configuring-resources-for-a-shared-drillbit/">Configuring Resources for a Shared Drillbit</a></li>
+              
+            </ul>
+            
+          
+            
+              <li class="toctree-l2"><a href="javascript: void(0);">Configuration Options</a></li>
+              <ul style="display: none">
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/configuration-options-introduction/">Configuration Options Introduction</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/start-up-options/">Start-Up Options</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/planning-and-execution-options/">Planning and Execution Options</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/persistent-configuration-storage/">Persistent Configuration Storage</a></li>
+              
+            </ul>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/starting-stopping-drill/">Starting/Stopping Drill</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/ports-used-by-drill/">Ports Used by Drill</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/partition-pruning/">Partition Pruning</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/monitoring-and-canceling-queries-in-the-drill-web-ui/">Monitoring and Canceling Queries in the Drill Web UI</a></li>
+            
+          
+          </ul>
+        
+      
+        
+          <li class="toctree-l1"><a href="javascript: void(0);">Developer Information</a></li>
+          <ul style="display: none">
+          
+            
+              <li class="toctree-l2"><a href="javascript: void(0);">Develop Drill</a></li>
+              <ul style="display: none">
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/compiling-drill-from-source/">Compiling Drill from Source</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/drill-patch-review-tool/">Drill Patch Review Tool</a></li>
+              
+            </ul>
+            
+          
+            
+              <li class="toctree-l2"><a href="javascript: void(0);">Contribute to Drill</a></li>
+              <ul style="display: none">
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/apache-drill-contribution-guidelines/">Apache Drill Contribution Guidelines</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/apache-drill-contribution-ideas/">Apache Drill Contribution Ideas</a></li>
+              
+            </ul>
+            
+          
+            
+              <li class="toctree-l2"><a href="javascript: void(0);">Design Docs</a></li>
+              <ul style="display: none">
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/drill-plan-syntax/">Drill Plan Syntax</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/rpc-overview/">RPC Overview</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/query-stages/">Query Stages</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/useful-research/">Useful Research</a></li>
+              
+                <li class="toctree-l3"><a class="reference internal" href="/docs/value-vectors/">Value Vectors</a></li>
+              
+            </ul>
+            
+          
+          </ul>
+        
+      
+        
+          <li class="toctree-l1"><a href="javascript: void(0);">Release Notes</a></li>
+          <ul style="display: none">
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/apache-drill-0-5-0-release-notes/">Apache Drill 0.5.0 Release Notes</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/apache-drill-0-4-0-release-notes/">Apache Drill 0.4.0 Release Notes</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/apache-drill-m1-release-notes-apache-drill-alpha/">Apache Drill M1 Release Notes (Apache Drill Alpha)</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/apache-drill-m1-release-notes-apache-drill-alpha/">Apache Drill M1 Release Notes (Apache Drill Alpha)</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/apache-drill-0-6-0-release-notes/">Apache Drill 0.6.0 Release Notes</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/apache-drill-0-7-0-release-notes/">Apache Drill 0.7.0 Release Notes</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/apache-drill-0-8-0-release-notes/">Apache Drill 0.8.0 Release Notes</a></li>
+            
+          
+          </ul>
+        
+      
+        
+          <li class="toctree-l1"><a href="javascript: void(0);">Sample Datasets</a></li>
+          <ul style="display: none">
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/aol-search/">AOL Search</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/enron-emails/">Enron Emails</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/wikipedia-edit-history/">Wikipedia Edit History</a></li>
+            
+          
+          </ul>
+        
+      
+        
+          <li class="toctree-l1"><a href="javascript: void(0);">Archived Pages</a></li>
+          <ul style="display: none">
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/how-to-run-the-drill-demo/">How to Run the Drill Demo</a></li>
+            
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/what-is-apache-drill/">What is Apache Drill</a></li>
+            
+          
+          </ul>
+        
+      
+        
+          <li class="toctree-l1"><a href="javascript: void(0);">Progress Reports</a></li>
+          <ul style="display: none">
+          
+            
+              <li class="toctree-l2"><a class="reference internal" href="/docs/2014-q1-drill-report/">2014 Q1 Drill Report</a></li>
+            
+          
+          </ul>
+        
+      
+        
+          <li class="toctree-l1"><a class="reference internal" href="/docs/project-bylaws/">Project Bylaws</a></li>
+        
+      
+      </ul>
+
+    </div>
+  </div>
+</aside>
+
+
+  <nav class="breadcrumbs">
+  <li><a href="/docs/">Docs</a></li>
+ 
+  
+    <li><a href="/docs/sql-reference/">SQL Reference</a></li>
+  
+    <li><a href="/docs/sql-functions/">SQL Functions</a></li>
+  
+  <li>Date/Time Functions and Arithmetic</li>
+</nav>
+
+  <div class="main-content-wrapper">
+    <div class="main-content">
+
+      
+        <a class="edit-link" href="https://github.com/apache/drill/blob/gh-pages/_docs/sql-reference/sql-functions/030-date-time-functions-and-arithmetic.md" target="_blank"><i class="fa fa-pencil-square-o"></i></a>
+      
+
+      <div class="int_title">
+        <h1>Date/Time Functions and Arithmetic</h1>
+
+      </div>
+
+      <link href="/css/docpage.css" rel="stylesheet" type="text/css">
+
+      <div class="int_text" align="left">
+        
+          <p>In addition to the TO_DATE, TO_TIME, and TO_TIMESTAMP functions, Drill supports a number of other date/time functions and arithmetic operators for use with dates, times, and intervals. Drill supports time functions based on the Gregorian calendar and in the range 1971 to 2037.</p>
+
+<p>This section defines the following date/time functions:</p>
+
+<table><thead>
+<tr>
+<th><strong>Function</strong></th>
+<th><strong>Return Type</strong></th>
+</tr>
+</thead><tbody>
+<tr>
+<td><a href="/docs/date-time-functions-and-arithmetic#age">AGE(TIMESTAMP)</a></td>
+<td>INTERVALDAY or INTERVALYEAR</td>
+</tr>
+<tr>
+<td><a href="/docs/date-time-functions-and-arithmetic#extract">EXTRACT(field from time_expression)</a></td>
+<td>DOUBLE</td>
+</tr>
+<tr>
+<td><a href="/docs/date-time-functions-and-arithmetic#current_*x*-local*x*-now-and-timeofday">CURRENT_DATE</a></td>
+<td>DATE</td>
+</tr>
+<tr>
+<td><a href="/docs/date-time-functions-and-arithmetic#current_*x*-local*x*-now-and-timeofday">CURRENT_TIME</a></td>
+<td>TIME</td>
+</tr>
+<tr>
+<td><a href="/docs/date-time-functions-and-arithmetic#current_*x*-local*x*-now-and-timeofday">CURRENT_TIMESTAMP</a></td>
+<td>TIMESTAMP</td>
+</tr>
+<tr>
+<td><a href="/docs/date-time-functions-and-arithmetic#date_add">DATE_ADD</a></td>
+<td>DATE, TIMESTAMP</td>
+</tr>
+<tr>
+<td><a href="/docs/date-time-functions-and-arithmetic#date_part">DATE_PART</a></td>
+<td>DOUBLE</td>
+</tr>
+<tr>
+<td><a href="/docs/date-time-functions-and-arithmetic#date_sub">DATE_SUB</a></td>
+<td>DATE, TIMESTAMOP</td>
+</tr>
+<tr>
+<td><a href="/docs/date-time-functions-and-arithmetic#current_*x*-local*x*-now-and-timeofday">LOCALTIME</a></td>
+<td>TIME</td>
+</tr>
+<tr>
+<td><a href="/docs/date-time-functions-and-arithmetic#current_*x*-local*x*-now-and-timeofday">LOCALTIMESTAMP</a></td>
+<td>TIMESTAMP</td>
+</tr>
+<tr>
+<td><a href="/docs/date-time-functions-and-arithmetic#current_*x*-local*x*-now-and-timeofday">NOW</a></td>
+<td>TIMESTAMP</td>
+</tr>
+<tr>
+<td><a href="/docs/date-time-functions-and-arithmetic#current_*x*-local*x*-now-and-timeofday">TIMEOFDAY</a></td>
+<td>VARCHAR</td>
+</tr>
+</tbody></table>
+
+<h2 id="age">AGE</h2>
+
+<p>Returns the interval between two timestamps or subtracts a timestamp from midnight of the current date.</p>
+
+<h3 id="age-syntax">AGE Syntax</h3>
+<div class="highlight"><pre><code class="language-text" data-lang="text">AGE (timestamp[, timestamp])
+</code></pre></div>
+<p><em>timestamp</em> is the data and time formatted as shown in the following examples.</p>
+
+<h3 id="age-usage-notes">AGE Usage Notes</h3>
+
+<p>Cast string arguments to timestamp to include time data in the calculations of the interval.</p>
+
+<h3 id="age-examples">AGE Examples</h3>
+
+<p>Find the interval between midnight April 3, 2015 and June 13, 1957.</p>
+<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT AGE(&#39;1957-06-13&#39;) FROM sys.version;
++------------+
+|   EXPR$0   |
++------------+
+| P703M23D   |
++------------+
+1 row selected (0.064 seconds)
+</code></pre></div>
+<p>Find the interval between 11:10:10 PM on January 1, 2001 and 10:10:10 PM on January 1, 2001.</p>
+<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT AGE(CAST(&#39;2010-01-01 10:10:10&#39; AS TIMESTAMP), CAST(&#39;2001-01-01 11:10:10&#39; AS TIMESTAMP)) FROM sys.version;
++------------+
+|   EXPR$0   |
++------------+
+| P109M16DT82800S |
++------------+
+1 row selected (0.161 seconds)
+</code></pre></div>
+<p>For information about how to read the interval data, see the <a href="/docs/date-time-and-timestamp#interval">Interval section</a>.</p>
+
+<h2 id="date_add">DATE_ADD</h2>
+
+<p>Returns the sum of a date/time and a number of days/hours, or of a date/time and date/time interval.</p>
+
+<h3 id="date_add-syntax">DATE_ADD Syntax</h3>
+<div class="highlight"><pre><code class="language-text" data-lang="text">DATE_ADD(date literal_date, integer)
+
+DATE_ADD(keyword literal, interval expr)
+</code></pre></div>
+<p><em>date</em> is the keyword date.<br>
+<em>literal_date</em> is a date in yyyy-mm-dd format enclosed in single quotation marks.<br>
+<em>integer</em> is a number of days to add to the date/time.  </p>
+
+<p><em>keyword</em> is the word date, time, or timestamp.<br>
+<em>literal</em> is a date, time, or timestamp literal.<br>
+<em>interval</em> is a keyword<br>
+<em>expr</em> is an interval expression.  </p>
+
+<h3 id="date_add-examples">DATE_ADD Examples</h3>
+
+<p>Add two days to today&#39;s date May 15, 2015.</p>
+<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT DATE_ADD(date &#39;2015-05-15&#39;, 2) FROM sys.version;
++------------+
+|   EXPR$0   |
++------------+
+| 2015-05-17 |
++------------+
+1 row selected (0.07 seconds)
+</code></pre></div>
+<p>Add two months to April 15, 2015.</p>
+<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT DATE_ADD(date &#39;2015-04-15&#39;, interval &#39;2&#39; month) FROM sys.version;
++------------+
+|   EXPR$0   |
++------------+
+| 2015-06-15 00:00:00.0 |
++------------+
+1 row selected (0.073 seconds)
+</code></pre></div>
+<p>Add 10 hours to the timestamp 2015-04-15 22:55:55.</p>
+<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT DATE_ADD(timestamp &#39;2015-04-15 22:55:55&#39;, interval &#39;10&#39; hour) FROM sys.version;
++------------+
+|   EXPR$0   |
++------------+
+| 2015-04-16 08:55:55.0 |
++------------+
+1 row selected (0.068 seconds)
+</code></pre></div>
+<p>Add 10 hours to the time 22 hours, 55 minutes, 55 seconds.</p>
+<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT DATE_ADD(time &#39;22:55:55&#39;, interval &#39;10&#39; hour) FROM sys.version;
++------------+
+|   EXPR$0   |
++------------+
+| 08:55:55   |
++------------+
+1 row selected (0.085 seconds)
+</code></pre></div>
+<p>Add 1 year and 1 month to the timestamp 2015-04-15 22:55:55.</p>
+<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT DATE_ADD(timestamp &#39;2015-04-15 22:55:55&#39;, interval &#39;1-2&#39; year to month) FROM sys.version;
++------------+
+|   EXPR$0   |
++------------+
+| 2016-06-15 22:55:55.0 |
++------------+
+1 row selected (0.065 seconds)
+</code></pre></div>
+<p>Add 1 day 2 and 1/2 hours and 45.100 seconds to the time 22:55:55.</p>
+<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT DATE_ADD(time &#39;22:55:55&#39;, interval &#39;1 2:30:45.100&#39; day to second) FROM sys.version;
++------------+
+|   EXPR$0   |
++------------+
+| 01:26:40.100 |
++------------+
+1 row selected (0.07 seconds)
+</code></pre></div>
+<h2 id="date_part">DATE_PART</h2>
+
+<p>Returns a field of a date, time, timestamp, or interval.</p>
+
+<h3 id="date_part-syntax">DATE_PART Syntax</h3>
+<div class="highlight"><pre><code class="language-text" data-lang="text">date_part(keyword, expression) 
+</code></pre></div>
+<p><em>keyword</em> is year, month, day, hour, minute, or second enclosed in single quotation marks.<br>
+<em>expression</em> is date, time, timestamp, or interval literal enclosed in single quotation marks.</p>
+
+<h3 id="date_part-usage-notes">DATE_PART Usage Notes</h3>
+
+<p>Use Unix Epoch timestamp in milliseconds as the expression to get the field of a timestamp.</p>
+
+<h3 id="date_part-examples">DATE_PART Examples</h3>
+<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT DATE_PART(&#39;day&#39;, &#39;2015-04-02&#39;) FROM sys.version;
++------------+
+|   EXPR$0   |
++------------+
+| 2          |
++------------+
+1 row selected (0.098 seconds)
+
+SELECT DATE_PART(&#39;hour&#39;, &#39;23:14:30.076&#39;) FROM sys.version;
++------------+
+|   EXPR$0   |
++------------+
+| 23         |
++------------+
+1 row selected (0.088 seconds)
+</code></pre></div>
+<p>Find the hour part of the timestamp for April 2, 2015 23:25:43. Use Unix Epoch timestamp in milliseconds, which is 1428017143000 in UTC.</p>
+<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT DATE_PART(&#39;hour&#39;, 1428017143000) FROM sys.version;
++------------+
+|   EXPR$0   |
++------------+
+| 23         |
++------------+
+1 row selected (0.07 seconds)
+</code></pre></div>
+<p>Return the day part of the one year, 2 months, 10 days interval.</p>
+<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT DATE_PART(&#39;day&#39;, &#39;1:2:10&#39;) FROM sys.version;
++------------+
+|   EXPR$0   |
++------------+
+| 10         |
++------------+
+1 row selected (0.069 seconds)
+</code></pre></div>
+<h2 id="date_sub">DATE_SUB</h2>
+
+<p>Returns the difference between a date/time and a number of days/hours, or between a date/time and date/time interval.</p>
+
+<h3 id="date_sub-syntax">DATE_SUB Syntax</h3>
+<div class="highlight"><pre><code class="language-text" data-lang="text">DATE_SUB(date literal_date, integer) 
+
+DATE_SUB(keyword literal, interval expr)  
+</code></pre></div>
+<p><em>date</em> is the keyword date.<br>
+<em>literal_date</em> is a date in yyyy-mm-dd format enclosed in single quotation marks.<br>
+<em>integer</em> is a number of days to subtract from the date/time.  </p>
+
+<p><em>keyword</em> is the word date, time, or timestamp.<br>
+<em>literal</em> is a date, time, or timestamp literal.<br>
+<em>interval</em> is a keyword.<br>
+<em>expr</em> is an interval expression.</p>
+
+<h3 id="date_sub-examples">DATE_SUB Examples</h3>
+
+<p>Subtract two days to today&#39;s date May 15, 2015.</p>
+<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT DATE_SUB(date &#39;2015-05-15&#39;, 2) FROM sys.version;
++------------+
+|   EXPR$0   |
++------------+
+| 2015-05-13 |
++------------+
+1 row selected (0.088 seconds)
+</code></pre></div>
+<p>Subtact two months from April 15, 2015.</p>
+<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT DATE_SUB(date &#39;2015-04-15&#39;, interval &#39;2&#39; month) FROM sys.version;
++------------+
+|   EXPR$0   |
++------------+
+| 2015-02-15 |
++------------+
+1 row selected (0.088 seconds)
+</code></pre></div>
+<p>Subtract 10 hours from the timestamp 2015-04-15 22:55:55.</p>
+<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT DATE_SUB(timestamp &#39;2015-04-15 22:55:55&#39;, interval &#39;10&#39; hour) FROM sys.version;
++------------+
+|   EXPR$0   |
++------------+
+| 2015-04-15 12:55:55.0 |
++------------+
+1 row selected (0.068 seconds)
+</code></pre></div>
+<p>Subtract 10 hours from the time 22 hours, 55 minutes, 55 seconds.</p>
+<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT DATE_SUB(time &#39;22:55:55&#39;, interval &#39;10&#39; hour) FROM sys.version;
++------------+
+|   EXPR$0   |
++------------+
+| 12:55:55   |
++------------+
+1 row selected (0.079 seconds)
+</code></pre></div>
+<p>Subtract 1 year and 1 month from the timestamp 2015-04-15 22:55:55.</p>
+<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT DATE_SUB(timestamp &#39;2015-04-15 22:55:55&#39;, interval &#39;1-2&#39; year to month) FROM sys.version;
++------------+
+|   EXPR$0   |
++------------+
+| 2014-02-15 22:55:55.0 |
++------------+
+1 row selected (0.073 seconds)
+</code></pre></div>
+<p>Subtract 1 day, 2 and 1/2 hours, and 45.100 seconds from the time 22:55:55.</p>
+<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT DATE_ADD(time &#39;22:55:55&#39;, interval &#39;1 2:30:45.100&#39; day to second) FROM sys.version;
++------------+
+|   EXPR$0   |
++------------+
+| 01:26:40.100 |
++------------+
+1 row selected (0.073 seconds)
+</code></pre></div>
+<h2 id="current_x,-local*x*,-now,-and-timeofday">CURRENT_<em>x</em>, LOCAL*x*, NOW, and TIMEOFDAY</h2>
+
+<p>The following examples show how to use these functions:</p>
+
+<ul>
+<li>CURRENT_DATE</li>
+<li>CURRENT_TIME</li>
+<li>CURRENT_TIMESTAMP</li>
+<li>LOCALTIME</li>
+<li>LOCALTIMESTAMP</li>
+<li>NOW</li>
+<li><p>TIMEOFDAY</p>
+
+<p>SELECT CURRENT_DATE FROM sys.version;
++--------------+
+| current_date |
++--------------+
+| 2015-04-02   |
++--------------+
+1 row selected (0.077 seconds)</p>
+
+<p>SELECT CURRENT_TIME FROM sys.version;
++--------------+
+| current_time |
++--------------+
+| 14:32:04.751 |
++--------------+
+1 row selected (0.073 seconds)</p>
+
+<p>SELECT CURRENT_TIMESTAMP FROM sys.version;
++-------------------+
+| current_timestamp |
++-------------------+
+| 2015-04-02 14:32:34.047 |
++-------------------+
+1 row selected (0.061 seconds)</p>
+
+<p>SELECT LOCALTIME FROM sys.version;</p>
+
+<p>+------------+
+| localtime  |
++------------+
+| 14:33:04.95 |
++------------+
+1 row selected (0.051 seconds)</p>
+
+<p>SELECT LOCALTIMESTAMP FROM sys.version;</p>
+
+<p>+----------------+
+| LOCALTIMESTAMP |
++----------------+
+| 2015-04-02 23:13:13.204 |
++----------------+
+1 row selected (0.105 seconds)</p>
+
+<p>SELECT NOW() FROM sys.version;
++------------+
+|   EXPR$0   |
++------------+
+| 2015-04-02 23:14:30.076 |
++------------+
+1 row selected (0.05 seconds)</p></li>
+</ul>
+
+<p>If you set up Drill for <a href="/docs/casting-converting-data-types/time-zone-limitation">UTC time</a>, TIMEOFDAY returns the result for the UTC time zone.</p>
+<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT TIMEOFDAY() FROM sys.version;
++------------+
+|   EXPR$0   |
++------------+
+| 2015-04-02 22:05:02.424 UTC |
++------------+
+1 row selected (1.191 seconds)
+</code></pre></div>
+<p>If you did not set up Drill for UTC time, TIMEOFDAY returns the local date and time with time zone information.</p>
+<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT TIMEOFDAY() FROM sys.version;
++------------+
+|   EXPR$0   |
++------------+
+| 2015-04-02 15:01:31.114 America/Los_Angeles |
++------------+
+1 row selected (1.199 seconds)
+</code></pre></div>
+<h2 id="extract">EXTRACT</h2>
+
+<p>Returns a component of a timestamp, time, date, or interval.</p>
+
+<h4 id="extract-syntax">EXTRACT Syntax</h4>
+<div class="highlight"><pre><code class="language-text" data-lang="text">EXTRACT (extract_expression) 
+</code></pre></div>
+<p><em>extract_expression</em> is:</p>
+<div class="highlight"><pre><code class="language-text" data-lang="text">component FROM (timestamp | time | date | interval)
+</code></pre></div>
+<p><em>component</em> is supported time unit.</p>
+
+<h3 id="extract-usage-notes">EXTRACT Usage Notes</h3>
+
+<p>The extract function supports the following time units: YEAR, MONTH, DAY, HOUR, MINUTE, SECOND.</p>
+
+<h3 id="extract-examples">EXTRACT Examples</h3>
+
+<p>On the third day of the month, run the following function:</p>
+<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT EXTRACT(day FROM NOW()), EXTRACT(day FROM CURRENT_DATE) FROM sys.version;
+
++------------+------------+
+|   EXPR$0   |   EXPR$1   |
++------------+------------+
+| 3          | 3          |
++------------+------------+
+1 row selected (0.208 seconds)
+</code></pre></div>
+<p>At 8:00 am, extract the hour from the value of CURRENT_DATE.</p>
+<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT EXTRACT(hour FROM CURRENT_DATE) FROM sys.version;
+
++------------+
+|   EXPR$0   |
++------------+
+| 8          |
++------------+
+</code></pre></div>
+<p>What is the hour component of this time: 17:12:28.5?</p>
+<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT EXTRACT(hour FROM TIME &#39;17:12:28.5&#39;) FROM sys.version;
+
++------------+
+|   EXPR$0   |
++------------+
+| 17         |
++------------+
+1 row selected (0.056 seconds)
+</code></pre></div>
+<p>What is the seconds component of this timestamp: 2001-02-16 20:38:40</p>
+<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT EXTRACT(SECOND FROM TIMESTAMP &#39;2001-02-16 20:38:40&#39;) FROM sys.version;
+
++------------+
+|   EXPR$0   |
++------------+
+| 40.0       |
++------------+
+1 row selected (0.062 seconds)
+</code></pre></div>
+<h2 id="date,-time,-and-interval-arithmetic-functions">Date, Time, and Interval Arithmetic Functions</h2>
+
+<p>Is the day returned from the NOW function the same as the day returned from the CURRENT_DATE function?</p>
+<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT EXTRACT(day FROM NOW()) = EXTRACT(day FROM CURRENT_DATE) FROM sys.version;
++------------+
+|   EXPR$0   |
++------------+
+| true       |
++------------+
+1 row selected (0.092 seconds)
+</code></pre></div>
+<p>Every 23 hours, a 4 hour task started. What time does the task end? </p>
+<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT TIME &#39;04:00:00&#39; + interval &#39;23:00:00&#39; hour to second FROM sys.version;
++------------+
+|   EXPR$0   |
++------------+
+| 03:00:00   |
++------------+
+1 row selected (0.097 seconds)
+</code></pre></div>
+<p>Is the time 2:00 PM?</p>
+<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT EXTRACT(hour FROM CURRENT_DATE) = 2 FROM sys.version;
++------------+
+|   EXPR$0   |
++------------+
+| false      |
++------------+
+1 row selected (0.033 seconds)
+</code></pre></div>
+      
+        
+          <div class="doc-nav">
+  
+  <span class="previous-toc"><a href="/docs/data-type-conversion/">← Data Type Conversion</a></span><span class="next-toc"><a href="/docs/string-manipulation/">String Manipulation →</a></span>
+</div>
+
+      
+      </div>
+    </div>
+  </div>
+
+  </div>
+  <p class="push"></p>
+<div id="footer" class="mw">
+<div class="wrapper">
+Copyright © 2012-2014 The Apache Software Foundation, licensed under the Apache License, Version 2.0.<br>
+Apache and the Apache feather logo are trademarks of The Apache Software Foundation. Other names appearing on the site may be trademarks of their respective owners.<br/><br/>
+</div>
+</div>
+
+  <script>
+(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
+
+ga('create', 'UA-53379651-1', 'auto');
+ga('send', 'pageview');
+</script>
+
+</body>
+</html>


Mime
View raw message