<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>OpenText Analytics Database 26.2.x – Date/time functions</title>
    <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/</link>
    <description>Recent content in Date/time functions on OpenText Analytics Database 26.2.x</description>
    <generator>Hugo -- gohugo.io</generator>
    
	  <atom:link href="/en/sql-reference/functions/data-type-specific-functions/datetime-functions/index.xml" rel="self" type="application/rss+xml" />
    
    
      
        
      
    
    
    <item>
      <title>Sql-Reference: ADD_MONTHS</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/add-months/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/add-months/</guid>
      <description>
        
        
        &lt;p&gt;Adds the specified number of months to a date and returns the sum as a &lt;code&gt;DATE&lt;/code&gt;. In general, ADD_MONTHS returns a date with the same day component as the start date. For example:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ADD_MONTHS (&amp;#39;2015-09-15&amp;#39;::date, -2) &amp;#34;2 Months Ago&amp;#34;;
 2 Months Ago
--------------
 2015-07-15
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Two exceptions apply:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;If the start date&#39;s day component is greater than the last day of the result month, ADD_MONTHS returns the last day of the result month. For example:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ADD_MONTHS (&amp;#39;31-Jan-2016&amp;#39;::TIMESTAMP, 1) &amp;#34;Leap Month&amp;#34;;
 Leap Month
------------
 2016-02-29
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If the start date&#39;s day component is the last day of that month, and the result month has more days than the start date month, ADD_MONTHS returns the last day of the result month. For example:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ADD_MONTHS (&amp;#39;2015-09-30&amp;#39;::date,-1) &amp;#34;1 Month Ago&amp;#34;;
 1 Month Ago
-------------
 2015-08-31
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if the &lt;em&gt;&lt;code&gt;start-date&lt;/code&gt;&lt;/em&gt; argument is a &lt;code&gt;TIMESTAMP&lt;/code&gt; or &lt;code&gt;DATE&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if the &lt;em&gt;&lt;code&gt;start-date&lt;/code&gt;&lt;/em&gt; argument is a &lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;ADD_MONTHS ( &lt;span class=&#34;code-variable&#34;&gt;start-date&lt;/span&gt;, &lt;span class=&#34;code-variable&#34;&gt;num-months&lt;/span&gt; );
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;start-date&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;The date to process, an expression that evaluates to one of the following data types:
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;DATE&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;TIMESTAMP&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;num-months&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;An integer expression that specifies the number of months to add to or subtract from &lt;em&gt;&lt;code&gt;start-date&lt;/code&gt;&lt;/em&gt;.&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;Add one month to the current date:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT CURRENT_DATE Today;
   Today
------------
 2016-05-05
(1 row)

VMart=&amp;gt; SELECT ADD_MONTHS(CURRENT_TIMESTAMP,1);
 ADD_MONTHS
------------
 2016-06-05
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Subtract four months from the current date:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ADD_MONTHS(CURRENT_TIMESTAMP, -4);
 ADD_MONTHS
------------
 2016-01-05
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Add one month to January 31 2016:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ADD_MONTHS(&amp;#39;31-Jan-2016&amp;#39;::TIMESTAMP, 1) &amp;#34;Leap Month&amp;#34;;
 Leap Month
------------
 2016-02-29
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The following example sets the timezone to EST; it then adds 24 months to a TIMESTAMPTZ that specifies a PST time zone, so &lt;code&gt;ADD_MONTHS&lt;/code&gt; takes into account the time change:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SET TIME ZONE &amp;#39;America/New_York&amp;#39;;
SET
VMart=&amp;gt; SELECT ADD_MONTHS(&amp;#39;2008-02-29 23:30 PST&amp;#39;::TIMESTAMPTZ, 24);
 ADD_MONTHS
------------
 2010-03-01
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: AGE_IN_MONTHS</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/age-in-months/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/age-in-months/</guid>
      <description>
        
        
        &lt;p&gt;Returns the difference in months between two dates, expressed as an integer.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if both date arguments are of data type TIMESTAMP&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if either date is a TIMESTAMPTZ or only one argument is supplied&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;AGE_IN_MONTHS ( [ &lt;span class=&#34;code-variable&#34;&gt;date1&lt;/span&gt;,] &lt;span class=&#34;code-variable&#34;&gt;date2&lt;/span&gt; )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;date1&lt;/code&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;code&gt;date2&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;Specify the boundaries of the period to measure. If you supply only one argument, OpenText™ Analytics Database sets &lt;em&gt;&lt;code&gt;date2&lt;/code&gt;&lt;/em&gt; to the current date. Both parameters must evaluate to one of the following data types:
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;DATE&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;TIMESTAMP&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If &lt;em&gt;&lt;code&gt;date1&lt;/code&gt;&lt;/em&gt; &amp;lt; &lt;em&gt;&lt;code&gt;date2&lt;/code&gt;&lt;/em&gt;, AGE_IN_MONTHS returns a negative value.&lt;/p&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;Get the age in months of someone born March 2 1972, as of June 21 1990:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT AGE_IN_MONTHS(&amp;#39;1990-06-21&amp;#39;::TIMESTAMP, &amp;#39;1972-03-02&amp;#39;::TIMESTAMP);
  AGE_IN_MONTHS
---------------
           219
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;If the first date is less than the second date, AGE_IN_MONTHS returns a negative value&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT AGE_IN_MONTHS(&amp;#39;1972-03-02&amp;#39;::TIMESTAMP, &amp;#39;1990-06-21&amp;#39;::TIMESTAMP);
AGE_IN_MONTHS
---------------
-220
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Get the age in months of someone who was born November 21 1939, as of today:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT AGE_IN_MONTHS (&amp;#39;1939-11-21&amp;#39;::DATE);
 AGE_IN_MONTHS
---------------
           930
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: AGE_IN_YEARS</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/age-in-years/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/age-in-years/</guid>
      <description>
        
        
        &lt;p&gt;Returns the difference in years between two dates, expressed as an integer.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if both date arguments are of data type TIMESTAMP&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if either date is a TIMESTAMPTZ or only one argument is supplied&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;AGE_IN_YEARS( [ &lt;span class=&#34;code-variable&#34;&gt;date1&lt;/span&gt;,] &lt;span class=&#34;code-variable&#34;&gt;date2&lt;/span&gt; )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;date1&lt;/code&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;code&gt;date2&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;Specify the boundaries of the period to measure. If you supply only one argument, OpenText™ Analytics Database sets &lt;em&gt;&lt;code&gt;date1&lt;/code&gt;&lt;/em&gt; to the current date. Both parameters must evaluate to one of the following data types:
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;DATE&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;TIMESTAMP&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If &lt;em&gt;&lt;code&gt;date1&lt;/code&gt;&lt;/em&gt; &amp;lt; &lt;em&gt;&lt;code&gt;date2&lt;/code&gt;&lt;/em&gt;, AGE_IN_YEARS returns a negative value.&lt;/p&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;Get the age of someone born March 2 1972, as of June 21 1990:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT AGE_IN_YEARS(&amp;#39;1990-06-21&amp;#39;::TIMESTAMP, &amp;#39;1972-03-02&amp;#39;::TIMESTAMP);
 AGE_IN_YEARS
--------------
           18
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;If the first date is earlier than the second date, AGE_IN_YEARS returns a negative number:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT AGE_IN_YEARS(&amp;#39;1972-03-02&amp;#39;::TIMESTAMP, &amp;#39;1990-06-21&amp;#39;::TIMESTAMP);
AGE_IN_YEARS
--------------
          -19
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Get the age of someone who was born November 21 1939, as of today:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT AGE_IN_YEARS(&amp;#39;1939-11-21&amp;#39;::DATE);
 AGE_IN_YEARS
--------------
           77
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: CLOCK_TIMESTAMP</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/clock-timestamp/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/clock-timestamp/</guid>
      <description>
        
        
        &lt;p&gt;Returns a value of type TIMESTAMP WITH TIMEZONE that represents the current system-clock time.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;CLOCK_TIMESTAMP&lt;/code&gt; uses the date and time supplied by the operating system on the server to which you are connected, which should be the same across all servers. The value changes each time you call it.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/volatile-functions/&#34; title=&#34;&#34;&gt;Volatile&lt;/a&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;CLOCK_TIMESTAMP()
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;The following command returns the current time on your system:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SELECT CLOCK_TIMESTAMP() &amp;#34;Current Time&amp;#34;;
         Current Time
------------------------------
 2010-09-23 11:41:23.33772-04
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Each time you call the function, you get a different result. The difference in this example is in microseconds:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SELECT CLOCK_TIMESTAMP() &amp;#34;Time 1&amp;#34;, CLOCK_TIMESTAMP() &amp;#34;Time 2&amp;#34;;
            Time 1             |            Time 2
-------------------------------+-------------------------------
 2010-09-23 11:41:55.369201-04 | 2010-09-23 11:41:55.369202-04
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/functions/data-type-specific-functions/datetime-functions/statement-timestamp/#&#34;&gt;STATEMENT_TIMESTAMP&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/functions/data-type-specific-functions/datetime-functions/transaction-timestamp/#&#34;&gt;TRANSACTION_TIMESTAMP&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: CURRENT_DATE</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/current-date/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/current-date/</guid>
      <description>
        
        
        &lt;p&gt;Returns the date (date-type value) on which the current transaction started.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;CURRENT_DATE()
&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&#34;alert admonition note&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Note&lt;/h4&gt;

You can call this function without parentheses.

&lt;/div&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SELECT CURRENT_DATE;
  ?column?
------------
 2010-09-23
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: CURRENT_TIME</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/current-time/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/current-time/</guid>
      <description>
        
        
        &lt;p&gt;Returns a value of type &lt;code&gt;TIME WITH TIMEZONE&lt;/code&gt; that represents the start of the current transaction.&lt;/p&gt;
&lt;p&gt;The return value does not change during the transaction. Thus, multiple calls to CURRENT_TIME within the same transaction return the same timestamp.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;CURRENT_TIME  [ ( &lt;span class=&#34;code-variable&#34;&gt;precision&lt;/span&gt; ) ]
&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&#34;alert admonition note&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Note&lt;/h4&gt;

If you specify a column label without precision, you must also omit parentheses.

&lt;/div&gt;
&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;precision&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;An integer value between 0-6, specifies to round the seconds fraction field result to the specified number of digits.&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
=&amp;gt; SELECT CURRENT_TIME(1) AS Time;
     Time
---------------
 06:51:45.2-07
(1 row)
=&amp;gt; SELECT CURRENT_TIME(5) AS Time;
       Time
-------------------
 06:51:45.18435-07
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: CURRENT_TIMESTAMP</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/current-timestamp/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/current-timestamp/</guid>
      <description>
        
        
        &lt;p&gt;Returns a value of type &lt;code&gt;TIMESTAMP WITH TIMEZONE&lt;/code&gt; that represents the start of the current transaction.&lt;/p&gt;
&lt;p&gt;The return value does not change during the transaction. Thus, multiple calls to &lt;code&gt;CURRENT_TIMESTAMP&lt;/code&gt; within the same transaction return the same timestamp.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;CURRENT_TIMESTAMP ( &lt;span class=&#34;code-variable&#34;&gt;precision&lt;/span&gt; )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;precision&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;An integer value between 0-6, specifies to round the seconds fraction field result to the specified number of digits.&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
=&amp;gt; SELECT CURRENT_TIMESTAMP(1) AS time;
           time
--------------------------
 2017-03-27 06:50:49.7-07
(1 row)
=&amp;gt; SELECT CURRENT_TIMESTAMP(5) AS time;
             time
------------------------------
 2017-03-27 06:50:49.69967-07
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: DATE</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/date/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/date/</guid>
      <description>
        
        
        &lt;p&gt;Converts the input value to a 
&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/date/#&#34;&gt;DATE&lt;/a&gt;&lt;/code&gt; data type.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if the input value is a &lt;code&gt;TIMESTAMP&lt;/code&gt;, &lt;code&gt;DATE&lt;/code&gt;, &lt;code&gt;VARCHAR&lt;/code&gt;, or integer&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if the input value is a &lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;DATE ( &lt;span class=&#34;code-variable&#34;&gt;value&lt;/span&gt; )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;value&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;The value to convert, one of the following:
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;TIMESTAMP&lt;/code&gt;, &lt;code&gt;TIMESTAMPTZ&lt;/code&gt;, &lt;code&gt;VARCHAR&lt;/code&gt;, or another &lt;code&gt;DATE&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Integer: OpenText™ Analytics Database treats the integer as the number of days since 01/01/0001 and returns the date.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT DATE (1);
    DATE
------------
 0001-01-01
(1 row)

=&amp;gt; SELECT DATE (734260);
    DATE
------------
 2011-05-03
(1 row)

=&amp;gt; SELECT DATE(&amp;#39;TODAY&amp;#39;);
    DATE
------------
 2016-12-07
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/formatting-functions/to-date/#&#34;&gt;TO_DATE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/formatting-functions/to-timestamp/#&#34;&gt;TO_TIMESTAMP&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/formatting-functions/to-timestamp-tz/#&#34;&gt;TO_TIMESTAMP_TZ&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: DATE_PART</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/date-part/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/date-part/</guid>
      <description>
        
        
        &lt;p&gt;Extracts a sub-field such as year or hour from a date/time expression, equivalent to the the SQL-standard function 
&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/functions/data-type-specific-functions/datetime-functions/extract/#&#34;&gt;EXTRACT&lt;/a&gt;&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if thespecified date is a &lt;code&gt;TIMESTAMP&lt;/code&gt;, &lt;code&gt;DATE&lt;/code&gt;, or &lt;code&gt;INTERVAL&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if the specified date is a &lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;DATE_PART ( &amp;#39;&lt;span class=&#34;code-variable&#34;&gt;field&lt;/span&gt;&amp;#39;, &lt;span class=&#34;code-variable&#34;&gt;date&lt;/span&gt; )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;field&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;A constant value that specifies the sub-field to extract from &lt;em&gt;&lt;code&gt;date&lt;/code&gt;&lt;/em&gt; (see &lt;a href=&#34;#FieldValues&#34;&gt;Field Values&lt;/a&gt; below).&lt;/dd&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;date&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;The date to process, an expression that evaluates to one of the following data types:
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/date/#&#34;&gt;DATE&lt;/a&gt; (cast to TIMESTAMP)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMP/TIMESTAMPTZ&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/interval/#&#34;&gt;INTERVAL&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/dd&gt;
&lt;/dl&gt;
&lt;p&gt;&lt;a name=&#34;FieldValues&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;field-values&#34;&gt;Field values&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;code&gt;CENTURY&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The century number.
&lt;p&gt;The first century starts at 0001-01-01 00:00:00 AD. This definition applies to all Gregorian calendar countries. There is no century number 0, you go from –1 to 1.&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;DAY&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The day (of the month) field (1–31).&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;DECADE&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The year field divided by 10.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;DOQ&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The day within the current quarter. DOQ recognizes leap year days.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;DOW&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Zero-based day of the week, where Sunday=0. 
&lt;div class=&#34;alert admonition note&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Note&lt;/h4&gt;

&lt;code&gt;EXTRACT&lt;/code&gt;&#39;s day of week numbering differs from the function
&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/functions/formatting-functions/to-char/#&#34;&gt;TO_CHAR&lt;/a&gt;&lt;/code&gt; .

&lt;/div&gt;&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;DOY&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The day of the year (1–365/366)&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;EPOCH&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Specifies to return one of the following:
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;For &lt;code&gt;DATE&lt;/code&gt; and &lt;code&gt;TIMESTAMP&lt;/code&gt; values: the number of seconds before or since 1970-01-01 00:00:00-00 (if before, a negative number).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;For &lt;code&gt;INTERVAL&lt;/code&gt; values, the total number of seconds in the interval.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;HOUR&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The hour field (0–23).&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;ISODOW&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The ISO day of the week, an integer between 1 and 7 where Monday is 1.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;ISOWEEK&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The ISO week of the year, an integer between 1 and 53.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;ISOYEAR&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The ISO year.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;MICROSECONDS&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The seconds field, including fractional parts, multiplied by 1,000,000. This includes full seconds.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;MILLENNIUM&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The millennium number, where the first millennium is 1 and each millenium starts on &lt;code&gt;01-01-&lt;/code&gt;&lt;em&gt;&lt;code&gt;y&lt;/code&gt;&lt;/em&gt;&lt;code&gt;001&lt;/code&gt;. For example, millennium 2 starts on 01-01-1001.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;MILLISECONDS&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The seconds field, including fractional parts, multiplied by 1000. This includes full seconds.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;MINUTE&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The minutes field (0 - 59).&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;MONTH&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;For &lt;code&gt;TIMESTAMP&lt;/code&gt; values, the number of the month within the year (1 - 12) ; for &lt;code&gt;interval&lt;/code&gt; values the number of months, modulo 12 (0 - 11).&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;QUARTER&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The calendar quarter of the specified date as an integer, where the January-March quarter is 1, valid only for &lt;code&gt;TIMESTAMP&lt;/code&gt; values.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;SECOND&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The seconds field, including fractional parts, 0–59, or 0-60 if the operating system implements leap seconds.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;TIME ZONE&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The time zone offset from UTC, in seconds. Positive values correspond to time zones east of UTC, negative values to zones west of UTC.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;TIMEZONE_HOUR&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The hour component of the time zone offset.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;TIMEZONE_MINUTE&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The minute component of the time zone offset.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;WEEK&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The number of the week of the calendar year that the day is in.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;YEAR&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The year field. There is no &lt;code&gt;0 AD&lt;/code&gt;, so subtract &lt;code&gt;BC&lt;/code&gt; years from &lt;code&gt;AD&lt;/code&gt; years accordingly.&lt;/dd&gt;
&lt;/dl&gt;

&lt;h2 id=&#34;notes&#34;&gt;Notes&lt;/h2&gt;
&lt;p&gt;According to the ISO-8601 standard, the week starts on Monday, and the first week of a year contains January 4. Thus, an early January date can sometimes be in the week 52 or 53 of the previous calendar year. For example:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT YEAR_ISO(&amp;#39;01-01-2016&amp;#39;::DATE), WEEK_ISO(&amp;#39;01-01-2016&amp;#39;), DAYOFWEEK_ISO(&amp;#39;01-01-2016&amp;#39;);
 YEAR_ISO | WEEK_ISO | DAYOFWEEK_ISO
----------+----------+---------------
     2015 |       53 |             5
(1 row)
&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;Extract the day value:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SELECT DATE_PART(&amp;#39;DAY&amp;#39;, TIMESTAMP &amp;#39;2009-02-24 20:38:40&amp;#39;) &amp;#34;Day&amp;#34;;
  Day
-----
  24
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Extract the month value:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SELECT DATE_PART(&amp;#39;MONTH&amp;#39;, &amp;#39;2009-02-24 20:38:40&amp;#39;::TIMESTAMP) &amp;#34;Month&amp;#34;;
  Month
-------
     2
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Extract the year value:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SELECT DATE_PART(&amp;#39;YEAR&amp;#39;, &amp;#39;2009-02-24 20:38:40&amp;#39;::TIMESTAMP) &amp;#34;Year&amp;#34;;
  Year
------
 2009
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Extract the hours:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SELECT DATE_PART(&amp;#39;HOUR&amp;#39;, &amp;#39;2009-02-24 20:38:40&amp;#39;::TIMESTAMP) &amp;#34;Hour&amp;#34;;
  Hour
------
   20
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Extract the minutes:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SELECT DATE_PART(&amp;#39;MINUTES&amp;#39;, &amp;#39;2009-02-24 20:38:40&amp;#39;::TIMESTAMP) &amp;#34;Minutes&amp;#34;;
  Minutes
---------
      38
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Extract the day of quarter (DOQ):&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SELECT DATE_PART(&amp;#39;DOQ&amp;#39;, &amp;#39;2009-02-24 20:38:40&amp;#39;::TIMESTAMP) &amp;#34;DOQ&amp;#34;;
 DOQ
-----
  55
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/formatting-functions/to-char/#&#34;&gt;TO_CHAR&lt;/a&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: DATE_TRUNC</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/date-trunc/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/date-trunc/</guid>
      <description>
        
        
        &lt;p&gt;Truncates date and time values to the specified precision. The return value is the same data type as the input value. All fields that are less than the specified precision are set to 0, or to 1 for day and month.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;DATE_TRUNC( &lt;span class=&#34;code-variable&#34;&gt;precision&lt;/span&gt;, &lt;span class=&#34;code-variable&#34;&gt;trunc-target&lt;/span&gt; )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;precision&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;A string constant that specifies precision for the truncated value. See &lt;a href=&#34;#PrecisionFieldValues&#34;&gt;Precision Field Values&lt;/a&gt; below. The precision must be valid for the &lt;em&gt;&lt;code&gt;trunc-target&lt;/code&gt;&lt;/em&gt; date or time.&lt;/dd&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;trunc-target&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;Valid date/time expression.&lt;/dd&gt;
&lt;/dl&gt;
&lt;p&gt;&lt;a name=&#34;PrecisionFieldValues&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;precision-field-values&#34;&gt;Precision field values&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;code&gt;MILLENNIUM&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The millennium number.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;CENTURY&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The century number.
&lt;p&gt;The first century starts at 0001-01-01 00:00:00 AD. This definition applies to all Gregorian calendar countries.&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;DECADE&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The year field divided by 10.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;YEAR&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The year field. Keep in mind there is no &lt;code&gt;0 AD&lt;/code&gt;, so subtract &lt;code&gt;BC&lt;/code&gt; years from &lt;code&gt;AD&lt;/code&gt; years with care.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;QUARTER&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The calendar quarter of the specified date as an integer, where the January-March quarter is 1.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;MONTH&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;For &lt;code&gt;timestamp&lt;/code&gt; values, the number of the month within the year (1–12) ; for &lt;code&gt;interval&lt;/code&gt; values the number of months, modulo 12 (0–11).&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;WEEK&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The number of the week of the year that the day is in.
&lt;p&gt;According to the ISO-8601 standard, the week starts on Monday, and the first week of a year contains January 4. Thus, an early January date can sometimes be in the week 52 or 53 of the previous calendar year. For example:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT YEAR_ISO(&amp;#39;01-01-2016&amp;#39;::DATE), WEEK_ISO(&amp;#39;01-01-2016&amp;#39;), DAYOFWEEK_ISO(&amp;#39;01-01-2016&amp;#39;);
 YEAR_ISO | WEEK_ISO | DAYOFWEEK_ISO
----------+----------+---------------
     2015 |       53 |             5
(1 row)
&lt;/code&gt;&lt;/pre&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;DAY&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The day (of the month) field (1–31).&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;HOUR&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The hour field (0–23).&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;MINUTE&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The minutes field (0–59).&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;SECOND&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The seconds field, including fractional parts (0–59) (60 if leap seconds are implemented by the operating system).&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;MILLISECONDS&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The seconds field, including fractional parts, multiplied by 1000. Note that this includes full seconds.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;MICROSECONDS&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The seconds field, including fractional parts, multiplied by 1,000,000. This includes full seconds.&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;The following example sets the field value as hour and returns the hour, truncating the minutes and seconds:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT DATE_TRUNC(&amp;#39;HOUR&amp;#39;, TIMESTAMP &amp;#39;2012-02-24 13:38:40&amp;#39;) AS HOUR;
        HOUR
---------------------
 2012-02-24 13:00:00
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The following example returns the year from the input &lt;code&gt;timestamptz &#39;2012-02-24 13:38:40&#39;&lt;/code&gt;. The function also defaults the month and day to January 1, truncates the hour:minute:second of the timestamp, and appends the time zone (&lt;code&gt;-05&lt;/code&gt;):&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT DATE_TRUNC(&amp;#39;YEAR&amp;#39;, TIMESTAMPTZ &amp;#39;2012-02-24 13:38:40&amp;#39;) AS YEAR;
          YEAR
------------------------
 2012-01-01 00:00:00-05
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The following example returns the year and month and defaults day of month to 1, truncating the rest of the string:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT DATE_TRUNC(&amp;#39;MONTH&amp;#39;, TIMESTAMP &amp;#39;2012-02-24 13:38:40&amp;#39;) AS MONTH;
        MONTH
---------------------
 2012-02-01 00:00:00
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: DATEDIFF</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/datediff/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/datediff/</guid>
      <description>
        
        
        &lt;p&gt;Returns the time span between two dates, in the intervals specified. &lt;code&gt;DATEDIFF&lt;/code&gt; excludes the start date in its calculation.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if start and end dates are &lt;code&gt;TIMESTAMP&lt;/code&gt; , &lt;code&gt;DATE&lt;/code&gt;, &lt;code&gt;TIME&lt;/code&gt;, or &lt;code&gt;INTERVAL&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if start and end dates are &lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;DATEDIFF ( &lt;span class=&#34;code-variable&#34;&gt;datepart&lt;/span&gt;, &lt;span class=&#34;code-variable&#34;&gt;start&lt;/span&gt;, &lt;span class=&#34;code-variable&#34;&gt;end&lt;/span&gt; );
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;datepart&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;Specifies the type of date or time intervals that &lt;code&gt;DATEDIFF&lt;/code&gt; returns. If &lt;em&gt;&lt;code&gt;datepart&lt;/code&gt;&lt;/em&gt; is an expression, it must be enclosed in parentheses:
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;DATEDIFF((&lt;span class=&#34;code-variable&#34;&gt;expression&lt;/span&gt;), &lt;span class=&#34;code-variable&#34;&gt;start&lt;/span&gt;, &lt;span class=&#34;code-variable&#34;&gt;end&lt;/span&gt;);
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;em&gt;&lt;code&gt;datepart&lt;/code&gt;&lt;/em&gt; must evaluate to one of the following string literals, either quoted or unquoted:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;year&lt;/code&gt; | &lt;code&gt;yy&lt;/code&gt; | &lt;code&gt;yyyy&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;quarter&lt;/code&gt; | &lt;code&gt;qq&lt;/code&gt; | &lt;code&gt;q&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;month&lt;/code&gt; | &lt;code&gt;mm&lt;/code&gt; | &lt;code&gt;m&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;day&lt;/code&gt; | &lt;code&gt;dayofyear&lt;/code&gt; | &lt;code&gt;dd&lt;/code&gt; | &lt;code&gt;d&lt;/code&gt; | &lt;code&gt;dy&lt;/code&gt; | &lt;code&gt;y&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;week&lt;/code&gt; | &lt;code&gt;wk&lt;/code&gt; | &lt;code&gt;ww&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;hour&lt;/code&gt; | &lt;code&gt;hh&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;minute&lt;/code&gt; | &lt;code&gt;mi&lt;/code&gt; | &lt;code&gt;n&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;second&lt;/code&gt; | &lt;code&gt;ss&lt;/code&gt; | &lt;code&gt;s&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;millisecond&lt;/code&gt; | &lt;code&gt;ms&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;microsecond&lt;/code&gt; | &lt;code&gt;mcs&lt;/code&gt; | &lt;code&gt;us&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;start&lt;/code&gt;&lt;/em&gt;&lt;code&gt;, &lt;/code&gt;&lt;em&gt;&lt;code&gt;end&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;Specify the start and end dates, where &lt;em&gt;&lt;code&gt;start&lt;/code&gt;&lt;/em&gt; and &lt;em&gt;&lt;code&gt;end&lt;/code&gt;&lt;/em&gt; evaluate to one of the following data types:
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMP/TIMESTAMPTZ&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/date/#&#34;&gt;DATE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timetimetz/#&#34;&gt;TIME/TIMETZ&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/interval/#&#34;&gt;INTERVAL&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If &lt;em&gt;&lt;code&gt;end&lt;/code&gt;&lt;/em&gt; &amp;lt; &lt;em&gt;&lt;code&gt;start&lt;/code&gt;&lt;/em&gt;, &lt;code&gt;DATEDIFF&lt;/code&gt; returns a negative value.

&lt;div class=&#34;alert admonition note&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Note&lt;/h4&gt;

&lt;code&gt;TIME&lt;/code&gt; and &lt;code&gt;INTERVAL&lt;/code&gt; data types are invalid for start and end dates if &lt;em&gt;&lt;code&gt;datepart&lt;/code&gt;&lt;/em&gt; is set to &lt;code&gt;year&lt;/code&gt;, &lt;code&gt;quarter&lt;/code&gt;, or &lt;code&gt;month&lt;/code&gt;.

&lt;/div&gt;&lt;/p&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;compatible-start-and-end-date-data-types&#34;&gt;Compatible start and end date data types&lt;/h2&gt;
&lt;p&gt;The following table shows which data types can be matched as start and end dates:

&lt;table class=&#34;table table-bordered&#34; &gt;



&lt;tr&gt; 

&lt;td &gt;
&lt;/td&gt; 

&lt;td &gt;
&lt;code&gt;DATE&lt;/code&gt;&lt;/td&gt; 

&lt;td &gt;
&lt;code&gt;TIMESTAMP&lt;/code&gt;&lt;/td&gt; 

&lt;td &gt;
&lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/td&gt; 

&lt;td &gt;
&lt;code&gt;TIME&lt;/code&gt;&lt;/td&gt; 

&lt;td &gt;
&lt;code&gt;INTERVAL&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
&lt;code&gt;DATE&lt;/code&gt;&lt;/td&gt; 


&lt;td  class=&#34;hcenter&#34; &gt;
•&lt;/td&gt; 


&lt;td  class=&#34;hcenter&#34; &gt;
•&lt;/td&gt; 


&lt;td  class=&#34;hcenter&#34; &gt;
•&lt;/td&gt; 


&lt;td  class=&#34;hcenter&#34; &gt;
&lt;/td&gt; 


&lt;td  class=&#34;hcenter&#34; &gt;
&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
&lt;code&gt;TIMESTAMP&lt;/code&gt;&lt;/td&gt; 


&lt;td  class=&#34;hcenter&#34; &gt;
•&lt;/td&gt; 


&lt;td  class=&#34;hcenter&#34; &gt;
•&lt;/td&gt; 


&lt;td  class=&#34;hcenter&#34; &gt;
•&lt;/td&gt; 


&lt;td  class=&#34;hcenter&#34; &gt;
&lt;/td&gt; 


&lt;td  class=&#34;hcenter&#34; &gt;
&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
&lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/td&gt; 


&lt;td  class=&#34;hcenter&#34; &gt;
•&lt;/td&gt; 


&lt;td  class=&#34;hcenter&#34; &gt;
•&lt;/td&gt; 


&lt;td  class=&#34;hcenter&#34; &gt;
•&lt;/td&gt; 


&lt;td  class=&#34;hcenter&#34; &gt;
&lt;/td&gt; 


&lt;td  class=&#34;hcenter&#34; &gt;
&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
&lt;code&gt;TIME&lt;/code&gt;&lt;/td&gt; 


&lt;td  class=&#34;hcenter&#34; &gt;
&lt;/td&gt; 


&lt;td  class=&#34;hcenter&#34; &gt;
&lt;/td&gt; 


&lt;td  class=&#34;hcenter&#34; &gt;
&lt;/td&gt; 


&lt;td  class=&#34;hcenter&#34; &gt;
•&lt;/td&gt; 


&lt;td  class=&#34;hcenter&#34; &gt;
&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
&lt;code&gt;INTERVAL&lt;/code&gt;&lt;/td&gt; 


&lt;td  class=&#34;hcenter&#34; &gt;
&lt;/td&gt; 


&lt;td  class=&#34;hcenter&#34; &gt;
&lt;/td&gt; 


&lt;td  class=&#34;hcenter&#34; &gt;
&lt;/td&gt; 


&lt;td  class=&#34;hcenter&#34; &gt;
&lt;/td&gt; 


&lt;td  class=&#34;hcenter&#34; &gt;
•&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/p&gt;
&lt;p&gt;For example, if you set the start date to an &lt;code&gt;INTERVAL&lt;/code&gt; data type, the end date must also be an &lt;code&gt;INTERVAL&lt;/code&gt;, otherwise OpenText™ Analytics Database returns an error:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt; SELECT DATEDIFF(day, INTERVAL &amp;#39;26 days&amp;#39;, INTERVAL &amp;#39;1 month &amp;#39;);
 datediff
----------
        4
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;date-part-intervals&#34;&gt;Date part intervals&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;DATEDIFF&lt;/code&gt; uses the &lt;em&gt;&lt;code&gt;datepart&lt;/code&gt;&lt;/em&gt; argument to calculate the number of intervals between two dates, rather than the actual amount of time between them. &lt;code&gt;DATEDIFF&lt;/code&gt; uses the following cutoff points to calculate those intervals:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;year&lt;/code&gt;: January 1&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;quarter&lt;/code&gt;: January 1, April 1, July 1, October 1&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;month&lt;/code&gt;: the first day of the month&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;week&lt;/code&gt;: Sunday at midnight (24:00)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For example, if &lt;em&gt;&lt;code&gt;datepart&lt;/code&gt;&lt;/em&gt; is set to &lt;code&gt;year&lt;/code&gt;, &lt;code&gt;DATEDIFF&lt;/code&gt; uses January 01 to calculate the number of years between two dates. The following &lt;code&gt;DATEDIFF&lt;/code&gt; statement sets &lt;em&gt;&lt;code&gt;datepart&lt;/code&gt;&lt;/em&gt; to &lt;code&gt;year&lt;/code&gt;, and specifies a time span 01/01/2005 - 06/15/2008:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SELECT DATEDIFF(year, &amp;#39;01-01-2005&amp;#39;::date, &amp;#39;12-31-2008&amp;#39;::date);
 datediff
----------
        3
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;code&gt;DATEDIFF&lt;/code&gt; always excludes the start date when it calculates intervals—in this case, 01/01//2005. &lt;code&gt;DATEDIFF&lt;/code&gt; considers only calendar year starts in its calculation, so in this case it only counts years 2006, 2007, and 2008. The function returns 3, although the actual time span is nearly four years.&lt;/p&gt;
&lt;p&gt;If you change the start and end dates to 12/31/2004 and 01/01/2009, respectively, &lt;code&gt;DATEDIFF&lt;/code&gt; also counts years 2005 and 2009. This time, it returns 5, although the actual time span is just over four years:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT DATEDIFF(year, &amp;#39;12-31-2004&amp;#39;::date, &amp;#39;01-01-2009&amp;#39;::date);
 datediff
----------
        5
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Similarly, &lt;code&gt;DATEDIFF&lt;/code&gt; uses month start dates when it calculates the number of months between two dates. Thus, given the following statement, &lt;code&gt;DATEDIFF&lt;/code&gt; counts months February through September and returns 8:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT DATEDIFF(month, &amp;#39;01-31-2005&amp;#39;::date, &amp;#39;09-30-2005&amp;#39;::date);
 datediff
----------
        8
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/data-type-specific-functions/datetime-functions/timestampdiff/#&#34;&gt;TIMESTAMPDIFF&lt;/a&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: DAY</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/day/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/day/</guid>
      <description>
        
        
        &lt;p&gt;Returns as an integer the day of the month from the input value.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if the input value is a &lt;code&gt;TIMESTAMP&lt;/code&gt;, &lt;code&gt;DATE&lt;/code&gt;, &lt;code&gt;VARCHAR&lt;/code&gt;, or &lt;code&gt;INTEGER&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if the specified date is a &lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;DAY ( &lt;span class=&#34;code-variable&#34;&gt;value&lt;/span&gt; )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;value&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;The value to convert, one of the following: &lt;code&gt;TIMESTAMP&lt;/code&gt;, &lt;code&gt;TIMESTAMPTZ&lt;/code&gt;, &lt;code&gt;INTERVAL&lt;/code&gt;, &lt;code&gt;VARCHAR&lt;/code&gt;, or &lt;code&gt;INTEGER&lt;/code&gt;.&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT DAY (6);
 DAY
-----
   6
(1 row)

=&amp;gt; SELECT DAY(TIMESTAMP &amp;#39;sep 22, 2011 12:34&amp;#39;);
 DAY
-----
  22
(1 row)

=&amp;gt; SELECT DAY(&amp;#39;sep 22, 2011 12:34&amp;#39;);
 DAY
-----
  22
(1 row)

=&amp;gt; SELECT DAY(INTERVAL &amp;#39;35 12:34&amp;#39;);
 DAY
-----
  35
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: DAYOFMONTH</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/dayofmonth/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/dayofmonth/</guid>
      <description>
        
        
        &lt;p&gt;Returns the day of the month as an integer.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if thetarget date is a &lt;code&gt;TIMESTAMP&lt;/code&gt;, &lt;code&gt;DATE&lt;/code&gt;, or &lt;code&gt;VARCHAR&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if the target date is a&lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;DAYOFMONTH ( &lt;span class=&#34;code-variable&#34;&gt;date&lt;/span&gt; )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;date&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;The date to process, one of the following data types:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/character-data-types-char-and-varchar/#&#34;&gt;VARCHAR&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/date/#&#34;&gt;DATE&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMP&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamp-time-zone/#&#34;&gt;TIMESTAMPTZ&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT DAYOFMONTH (TIMESTAMP &amp;#39;sep 22, 2011 12:34&amp;#39;);
 DAYOFMONTH
------------
         22
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: DAYOFWEEK</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/dayofweek/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/dayofweek/</guid>
      <description>
        
        
        &lt;p&gt;Returns the day of the week as an integer, where Sunday is day 1.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if thetarget date is a &lt;code&gt;TIMESTAMP&lt;/code&gt;, &lt;code&gt;DATE&lt;/code&gt;, or &lt;code&gt;VARCHAR&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if the target date is a&lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;DAYOFWEEK ( &lt;span class=&#34;code-variable&#34;&gt;date&lt;/span&gt; )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;date&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;The date to process, one of the following data types:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/character-data-types-char-and-varchar/#&#34;&gt;VARCHAR&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/date/#&#34;&gt;DATE&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMP&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamp-time-zone/#&#34;&gt;TIMESTAMPTZ&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT DAYOFWEEK (TIMESTAMP &amp;#39;sep 17, 2011 12:34&amp;#39;);
 DAYOFWEEK
-----------
         7
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: DAYOFWEEK_ISO</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/dayofweek-iso/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/dayofweek-iso/</guid>
      <description>
        
        
        &lt;p&gt;Returns the ISO 8061 day of the week as an integer, where Monday is day 1.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if thetarget date is a &lt;code&gt;TIMESTAMP&lt;/code&gt;, &lt;code&gt;DATE&lt;/code&gt;, or &lt;code&gt;VARCHAR&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if the target date is a&lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;DAYOFWEEK_ISO ( &lt;span class=&#34;code-variable&#34;&gt;date&lt;/span&gt; )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;date&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;The date to process, one of the following data types:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/character-data-types-char-and-varchar/#&#34;&gt;VARCHAR&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/date/#&#34;&gt;DATE&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMP&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamp-time-zone/#&#34;&gt;TIMESTAMPTZ&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT DAYOFWEEK_ISO(TIMESTAMP &amp;#39;Sep 22, 2011 12:34&amp;#39;);
 DAYOFWEEK_ISO
---------------
             4
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The following example shows how to combine the DAYOFWEEK_ISO, WEEK_ISO, and YEAR_ISO functions to find the ISO day of the week, week, and year:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT DAYOFWEEK_ISO(&amp;#39;Jan 1, 2000&amp;#39;), WEEK_ISO(&amp;#39;Jan 1, 2000&amp;#39;),YEAR_ISO(&amp;#39;Jan1,2000&amp;#39;);
 DAYOFWEEK_ISO | WEEK_ISO | YEAR_ISO
---------------+----------+----------
             6 |       52 |     1999
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/data-type-specific-functions/datetime-functions/week-iso/#&#34;&gt;WEEK_ISO&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/data-type-specific-functions/datetime-functions/dayofweek-iso/#&#34;&gt;DAYOFWEEK_ISO&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;http://en.wikipedia.org/wiki/ISO_8601&#34;&gt;http://en.wikipedia.org/wiki/ISO_8601&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: DAYOFYEAR</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/dayofyear/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/dayofyear/</guid>
      <description>
        
        
        &lt;p&gt;Returns the day of the year as an integer, where January 1 is day 1.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if thespecified date is a &lt;code&gt;TIMESTAMP&lt;/code&gt;, &lt;code&gt;DATE&lt;/code&gt;, or &lt;code&gt;VARCHAR&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if the specified date is a&lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;DAYOFYEAR ( &lt;span class=&#34;code-variable&#34;&gt;date&lt;/span&gt; )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;date&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;The date to process, one of the following data types:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/character-data-types-char-and-varchar/#&#34;&gt;VARCHAR&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/date/#&#34;&gt;DATE&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMP&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamp-time-zone/#&#34;&gt;TIMESTAMPTZ&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT DAYOFYEAR (TIMESTAMP &amp;#39;SEPT 22,2011 12:34&amp;#39;);
 DAYOFYEAR
-----------
       265
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: DAYS</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/days/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/days/</guid>
      <description>
        
        
        &lt;p&gt;Returns the integer value of the specified date, where 1 AD is 1. If the date precedes 1 AD, &lt;code&gt;DAYS&lt;/code&gt; returns a negative integer.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if thespecified date is a &lt;code&gt;TIMESTAMP&lt;/code&gt;, &lt;code&gt;DATE&lt;/code&gt;, or &lt;code&gt;VARCHAR&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if the specified date is a&lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;DAYS ( &lt;span class=&#34;code-variable&#34;&gt;date&lt;/span&gt; )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;date&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;The date to process, one of the following data types:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/character-data-types-char-and-varchar/#&#34;&gt;VARCHAR&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/date/#&#34;&gt;DATE&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMP&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamp-time-zone/#&#34;&gt;TIMESTAMPTZ&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT DAYS (DATE &amp;#39;2011-01-22&amp;#39;);
  DAYS
--------
 734159
(1 row)

=&amp;gt; SELECT DAYS (DATE &amp;#39;March 15, 0044 BC&amp;#39;);
  DAYS
--------
 -15997
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: EXTRACT</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/extract/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/extract/</guid>
      <description>
        
        
        &lt;p&gt;Retrieves sub-fields such as year or hour from date/time values and returns values of type 
&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/numeric-data-types/numeric/#&#34;&gt;NUMERIC&lt;/a&gt;&lt;/code&gt;. &lt;code&gt;EXTRACT&lt;/code&gt; is intended for computational processing, rather than for formatting date/time values for display.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if the specified date is a &lt;code&gt;TIMESTAMP&lt;/code&gt;, &lt;code&gt;DATE&lt;/code&gt;, or &lt;code&gt;INTERVAL&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if the specified date is a&lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;EXTRACT ( &lt;span class=&#34;code-variable&#34;&gt;field&lt;/span&gt; FROM &lt;span class=&#34;code-variable&#34;&gt;date&lt;/span&gt; )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;field&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;A constant value that specifies the sub-field to extract from &lt;em&gt;&lt;code&gt;date&lt;/code&gt;&lt;/em&gt; (see &lt;a href=&#34;#FieldValues&#34;&gt;Field Values&lt;/a&gt; below).&lt;/dd&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;date&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;The date to process, an expression that evaluates to one of the following data types:
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/date/#&#34;&gt;DATE&lt;/a&gt; (cast to TIMESTAMP)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMP/TIMESTAMPTZ&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/interval/#&#34;&gt;INTERVAL&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/dd&gt;
&lt;/dl&gt;
&lt;p&gt;&lt;a name=&#34;FieldValues&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;field-values&#34;&gt;Field values&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;code&gt;CENTURY&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The century number.
&lt;p&gt;The first century starts at 0001-01-01 00:00:00 AD. This definition applies to all Gregorian calendar countries. There is no century number 0, you go from –1 to 1.&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;DAY&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The day (of the month) field (1–31).&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;DECADE&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The year field divided by 10.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;DOQ&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The day within the current quarter. DOQ recognizes leap year days.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;DOW&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Zero-based day of the week, where Sunday=0. 
&lt;div class=&#34;alert admonition note&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Note&lt;/h4&gt;

&lt;code&gt;EXTRACT&lt;/code&gt;&#39;s day of week numbering differs from the function
&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/functions/formatting-functions/to-char/#&#34;&gt;TO_CHAR&lt;/a&gt;&lt;/code&gt; .

&lt;/div&gt;&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;DOY&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The day of the year (1–365/366)&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;EPOCH&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Specifies to return one of the following:
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;For &lt;code&gt;DATE&lt;/code&gt; and &lt;code&gt;TIMESTAMP&lt;/code&gt; values: the number of seconds before or since 1970-01-01 00:00:00-00 (if before, a negative number).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;For &lt;code&gt;INTERVAL&lt;/code&gt; values, the total number of seconds in the interval.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;HOUR&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The hour field (0–23).&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;ISODOW&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The ISO day of the week, an integer between 1 and 7 where Monday is 1.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;ISOWEEK&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The ISO week of the year, an integer between 1 and 53.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;ISOYEAR&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The ISO year.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;MICROSECONDS&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The seconds field, including fractional parts, multiplied by 1,000,000. This includes full seconds.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;MILLENNIUM&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The millennium number, where the first millennium is 1 and each millenium starts on &lt;code&gt;01-01-&lt;/code&gt;&lt;em&gt;&lt;code&gt;y&lt;/code&gt;&lt;/em&gt;&lt;code&gt;001&lt;/code&gt;. For example, millennium 2 starts on 01-01-1001.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;MILLISECONDS&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The seconds field, including fractional parts, multiplied by 1000. This includes full seconds.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;MINUTE&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The minutes field (0 - 59).&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;MONTH&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;For &lt;code&gt;TIMESTAMP&lt;/code&gt; values, the number of the month within the year (1 - 12) ; for &lt;code&gt;interval&lt;/code&gt; values the number of months, modulo 12 (0 - 11).&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;QUARTER&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The calendar quarter of the specified date as an integer, where the January-March quarter is 1, valid only for &lt;code&gt;TIMESTAMP&lt;/code&gt; values.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;SECOND&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The seconds field, including fractional parts, 0–59, or 0-60 if the operating system implements leap seconds.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;TIME ZONE&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The time zone offset from UTC, in seconds. Positive values correspond to time zones east of UTC, negative values to zones west of UTC.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;TIMEZONE_HOUR&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The hour component of the time zone offset.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;TIMEZONE_MINUTE&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The minute component of the time zone offset.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;WEEK&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The number of the week of the calendar year that the day is in.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;YEAR&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;The year field. There is no &lt;code&gt;0 AD&lt;/code&gt;, so subtract &lt;code&gt;BC&lt;/code&gt; years from &lt;code&gt;AD&lt;/code&gt; years accordingly.&lt;/dd&gt;
&lt;/dl&gt;

&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;Extract the day of the week and day in quarter from the current TIMESTAMP:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT CURRENT_TIMESTAMP AS NOW;
              NOW
-------------------------------
 2016-05-03 11:36:08.829004-04
(1 row)
=&amp;gt; SELECT EXTRACT (DAY FROM CURRENT_TIMESTAMP);
 date_part
-----------
         3
(1 row)
=&amp;gt; SELECT EXTRACT (DOQ FROM CURRENT_TIMESTAMP);
 date_part
-----------
        33
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Extract the timezone hour from the current time:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT CURRENT_TIMESTAMP;
           ?column?
-------------------------------
 2016-05-03 11:36:08.829004-04
(1 row)

=&amp;gt;  SELECT EXTRACT(TIMEZONE_HOUR FROM CURRENT_TIMESTAMP);
 date_part
-----------
        -4
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Extract the number of seconds since 01-01-1970 00:00:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT EXTRACT(EPOCH FROM &amp;#39;2001-02-16 20:38:40-08&amp;#39;::TIMESTAMPTZ);
    date_part
------------------
 982384720.000000
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Extract the number of seconds between 01-01-1970 00:00 and 5 days 3 hours before:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT EXTRACT(EPOCH FROM -&amp;#39;5 days 3 hours&amp;#39;::INTERVAL);
   date_part
----------------
 -442800.000000
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Convert the results from the last example to a TIMESTAMP:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT &amp;#39;EPOCH&amp;#39;::TIMESTAMPTZ -442800  * &amp;#39;1 second&amp;#39;::INTERVAL;
        ?column?
------------------------
 1969-12-26 16:00:00-05
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: GETDATE</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/getdate/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/getdate/</guid>
      <description>
        
        
        &lt;p&gt;Returns the current statement&#39;s start date and time as a &lt;code&gt;TIMESTAMP&lt;/code&gt; value. This function is identical to 
&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/functions/data-type-specific-functions/datetime-functions/sysdate/#&#34;&gt;SYSDATE&lt;/a&gt;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;GETDATE&lt;/code&gt; uses the date and time supplied by the operating system on the server to which you are connected, which is the same across all servers. Internally, &lt;code&gt;GETDATE&lt;/code&gt; converts 
&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/functions/data-type-specific-functions/datetime-functions/statement-timestamp/#&#34;&gt;STATEMENT_TIMESTAMP&lt;/a&gt;&lt;/code&gt; from &lt;code&gt;TIMESTAMPTZ&lt;/code&gt; to &lt;code&gt;TIMESTAMP&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;GETDATE()
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT GETDATE();
          GETDATE
----------------------------
 2011-03-07 13:21:29.497742
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;a href=&#34;../../../../../en/sql-reference/language-elements/expressions/datetime-expressions/#&#34;&gt;Date/time expressions&lt;/a&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: GETUTCDATE</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/getutcdate/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/getutcdate/</guid>
      <description>
        
        
        &lt;p&gt;Returns the current statement&#39;s start date and time as a &lt;code&gt;TIMESTAMP&lt;/code&gt; value.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;GETUTCDATE&lt;/code&gt; uses the date and time supplied by the operating system on the server to which you are connected, which is the same across all servers. Internally, &lt;code&gt;GETUTCDATE&lt;/code&gt; converts 
&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/functions/data-type-specific-functions/datetime-functions/statement-timestamp/#&#34;&gt;STATEMENT_TIMESTAMP&lt;/a&gt;&lt;/code&gt; at TIME ZONE &#39;UTC&#39;.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;GETUTCDATE()
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT GETUTCDATE();
         GETUTCDATE
----------------------------
 2011-03-07 20:20:26.193052
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;../../../../../en/sql-reference/language-elements/expressions/datetime-expressions/#&#34;&gt;Date/time expressions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: HOUR</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/hour/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/hour/</guid>
      <description>
        
        
        &lt;p&gt;Returns the hour portion of the specified date as an integer, where 0 is 00:00 to 00:59.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if thespecified date is a &lt;code&gt;TIMESTAMP&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if the specified date is a&lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;HOUR( &lt;span class=&#34;code-variable&#34;&gt;date&lt;/span&gt; )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;date&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;The date to process, one of the following data types:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/character-data-types-char-and-varchar/#&#34;&gt;VARCHAR&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/date/#&#34;&gt;DATE&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMP&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamp-time-zone/#&#34;&gt;TIMESTAMPTZ&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/interval/#&#34;&gt;INTERVAL&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT HOUR (TIMESTAMP &amp;#39;sep 22, 2011 12:34&amp;#39;);
 HOUR
------
   12
(1 row)
=&amp;gt; SELECT HOUR (INTERVAL &amp;#39;35 12:34&amp;#39;);
 HOUR
------
   12
(1 row)
=&amp;gt; SELECT HOUR (&amp;#39;12:34&amp;#39;);
 HOUR
------
   12
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: ISFINITE</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/isfinite/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/isfinite/</guid>
      <description>
        
        
        &lt;p&gt;Tests for the special TIMESTAMP constant &lt;code&gt;INFINITY&lt;/code&gt; and returns a value of type BOOLEAN.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;ISFINITE ( &lt;span class=&#34;code-variable&#34;&gt;timestamp&lt;/span&gt; )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;timestamp&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;Expression of type TIMESTAMP&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SELECT ISFINITE(TIMESTAMP &amp;#39;2009-02-16 21:28:30&amp;#39;);
 ISFINITE
----------
 t
(1 row)
SELECT ISFINITE(TIMESTAMP &amp;#39;INFINITY&amp;#39;);
 ISFINITE
----------
 f
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: JULIAN_DAY</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/julian-day/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/julian-day/</guid>
      <description>
        
        
        &lt;p&gt;Returns the integer value of the specified day according to the Julian calendar, where day 1 is the first day of the Julian period, January 1, 4713 BC (on the Gregorian calendar, November 24, 4714 BC).&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if thespecified date is a &lt;code&gt;TIMESTAMP&lt;/code&gt;, &lt;code&gt;DATE&lt;/code&gt;, or &lt;code&gt;VARCHAR&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if the specified date is a&lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;JULIAN_DAY ( &lt;span class=&#34;code-variable&#34;&gt;date&lt;/span&gt; )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;date&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;The date to process, one of the following data types:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/character-data-types-char-and-varchar/#&#34;&gt;VARCHAR&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/date/#&#34;&gt;DATE&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMP&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamp-time-zone/#&#34;&gt;TIMESTAMPTZ&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT JULIAN_DAY (DATE &amp;#39;MARCH 15, 0044 BC&amp;#39;);
 JULIAN_DAY
------------
    1705428
(1 row)

=&amp;gt; SELECT JULIAN_DAY (DATE &amp;#39;2001-01-01&amp;#39;);
 JULIAN_DAY
------------
    2451911
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: LAST_DAY</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/last-day/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/last-day/</guid>
      <description>
        
        
        &lt;p&gt;Returns the last day of the month in the specified date.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if the specified is a &lt;code&gt;TIMESTAMP&lt;/code&gt; or &lt;code&gt;DATE&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if the specified date is a &lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;LAST_DAY ( &lt;span class=&#34;code-variable&#34;&gt;date&lt;/span&gt; )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;date&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;The date to process, one of the following data types:
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/date/#&#34;&gt;DATE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMP&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamp-time-zone/#&#34;&gt;TIMESTAMPTZ&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;calculating-first-day-of-month&#34;&gt;Calculating first day of month&lt;/h2&gt;
&lt;p&gt;SQL does not support any function that returns the first day in the month of a given date. You must use other functions to work around this limitation. For example:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT DATE (&amp;#39;2022/07/04&amp;#39;) - DAYOFMONTH (&amp;#39;2022/07/04&amp;#39;) +1;
  ?column?
------------
 2022-07-01
(1 row)

=&amp;gt; SELECT LAST_DAY(&amp;#39;1929/06/06&amp;#39;) - (SELECT DAY(LAST_DAY(&amp;#39;1929/06/06&amp;#39;))-1);
  ?column?
------------
 1929-06-01
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;The following example returns the last day of February as 29 because 2016 is a leap year:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT LAST_DAY(&amp;#39;2016-02-28 23:30 PST&amp;#39;) &amp;#34;Last Day&amp;#34;;
  Last Day
------------
 2016-02-29
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The following example returns the last day of February in a non-leap year:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;&amp;gt; SELECT LAST_DAY(&amp;#39;2017/02/03&amp;#39;) &amp;#34;Last&amp;#34;;
    Last
------------
 2017-02-28
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The following example returns the last day of March, after converting the string value to the specified DATE type:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT LAST_DAY(&amp;#39;2003/03/15&amp;#39;) &amp;#34;Last&amp;#34;;
    Last
------------
 2012-03-31
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: LOCALTIME</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/localtime/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/localtime/</guid>
      <description>
        
        
        &lt;p&gt;Returns a value of type &lt;code&gt;TIME&lt;/code&gt; that represents the start of the current transaction.&lt;/p&gt;
&lt;p&gt;The return value does not change during the transaction. Thus, multiple calls to &lt;code&gt;LOCALTIME&lt;/code&gt; within the same transaction return the same timestamp.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;LOCALTIME [ ( &lt;span class=&#34;code-variable&#34;&gt;precision&lt;/span&gt; ) ]
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;precision&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;Rounds the result to the specified number of fractional digits in the seconds field.&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE TABLE t1 (a int, b int);
CREATE TABLE

=&amp;gt; INSERT INTO t1 VALUES (1,2);
 OUTPUT
--------
      1
(1 row)

=&amp;gt; SELECT LOCALTIME time;
    time
-----------------
 15:03:14.595296
(1 row)

=&amp;gt; INSERT INTO t1 VALUES (3,4);
 OUTPUT
--------
      1
(1 row)

=&amp;gt; SELECT LOCALTIME;
    time
-----------------
 15:03:14.595296
(1 row)

=&amp;gt; COMMIT;
COMMIT
=&amp;gt; SELECT LOCALTIME;
    time
-----------------
 15:03:49.738032
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: LOCALTIMESTAMP</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/localtimestamp/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/localtimestamp/</guid>
      <description>
        
        
        &lt;p&gt;Returns a value of type &lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMP/TIMESTAMPTZ&lt;/a&gt; that represents the start of the current transaction, and remains unchanged until the transaction is closed. Thus, multiple calls to LOCALTIMESTAMP within a given transaction return the same timestamp.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;LOCALTIMESTAMP [ ( &lt;span class=&#34;code-variable&#34;&gt;precision&lt;/span&gt; ) ]
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;precision&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;Rounds the result to the specified number of fractional digits in the seconds field.&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE TABLE t1 (a int, b int);
CREATE TABLE
=&amp;gt; INSERT INTO t1 VALUES (1,2);
 OUTPUT
--------
      1
(1 row)

=&amp;gt; SELECT LOCALTIMESTAMP(2) AS &amp;#39;local timestamp&amp;#39;;
    local timestamp
------------------------
 2021-03-05 10:48:58.26
(1 row)

=&amp;gt; INSERT INTO t1 VALUES (3,4);
 OUTPUT
--------
      1
(1 row)

=&amp;gt; SELECT LOCALTIMESTAMP(2) AS &amp;#39;local timestamp&amp;#39;;
    local timestamp
------------------------
 2021-03-05 10:48:58.26
(1 row)

=&amp;gt; COMMIT;
COMMIT
=&amp;gt; SELECT LOCALTIMESTAMP(2) AS &amp;#39;local timestamp&amp;#39;;
    local timestamp
------------------------
 2021-03-05 10:50:08.99
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: MICROSECOND</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/microsecond/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/microsecond/</guid>
      <description>
        
        
        &lt;p&gt;Returns the microsecond portion of the specified date as an integer.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if thespecified date is a &lt;code&gt;TIMESTAMP&lt;/code&gt;, &lt;code&gt;INTERVAL&lt;/code&gt;, or &lt;code&gt;VARCHAR&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if the specified date is a&lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;MICROSECOND ( &lt;span class=&#34;code-variable&#34;&gt;date&lt;/span&gt; )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;date&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;The date to process, one of the following data types:
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/character-data-types-char-and-varchar/#&#34;&gt;VARCHAR&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMP&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamp-time-zone/#&#34;&gt;TIMESTAMPTZ&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/interval/#&#34;&gt;INTERVAL&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT MICROSECOND (TIMESTAMP &amp;#39;Sep 22, 2011 12:34:01.123456&amp;#39;);
 MICROSECOND
-------------
      123456
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: MIDNIGHT_SECONDS</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/midnight-seconds/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/midnight-seconds/</guid>
      <description>
        
        
        &lt;p&gt;Within the specified date, returns the number of seconds between midnight and the date&#39;s time portion.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if thespecified date is a &lt;code&gt;TIMESTAMP&lt;/code&gt;, &lt;code&gt;DATE&lt;/code&gt;, or &lt;code&gt;VARCHAR&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if the specified date is a&lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;MIDNIGHT_SECONDS ( &lt;span class=&#34;code-variable&#34;&gt;date&lt;/span&gt; )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;date&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;The date to process, one of the following data types:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/character-data-types-char-and-varchar/#&#34;&gt;VARCHAR&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/date/#&#34;&gt;DATE&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMP&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamp-time-zone/#&#34;&gt;TIMESTAMPTZ&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;Get the number of seconds since midnight:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT MIDNIGHT_SECONDS(CURRENT_TIMESTAMP);
 MIDNIGHT_SECONDS
------------------
            36480
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Get the number of seconds between midnight and noon on March 3 2016:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT MIDNIGHT_SECONDS(&amp;#39;3-3-2016 12:00&amp;#39;::TIMESTAMP);
 MIDNIGHT_SECONDS
------------------
            43200
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: MINUTE</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/minute/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/minute/</guid>
      <description>
        
        
        &lt;p&gt;Returns the minute portion of the specified date as an integer.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if thespecified date is a &lt;code&gt;TIMESTAMP&lt;/code&gt;, &lt;code&gt;DATE&lt;/code&gt;, &lt;code&gt;VARCHAR&lt;/code&gt; or &lt;code&gt;INTERVAL&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if the specified date is a&lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;MINUTE ( &lt;span class=&#34;code-variable&#34;&gt;date&lt;/span&gt; )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;date&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;The date to process, one of the following data types:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/character-data-types-char-and-varchar/#&#34;&gt;VARCHAR&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/date/#&#34;&gt;DATE&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMP&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamp-time-zone/#&#34;&gt;TIMESTAMPTZ&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/interval/#&#34;&gt;INTERVAL&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT MINUTE(&amp;#39;12:34:03.456789&amp;#39;);
 MINUTE
--------
     34
(1 row)
=&amp;gt;SELECT MINUTE (TIMESTAMP &amp;#39;sep 22, 2011 12:34&amp;#39;);
 MINUTE
--------
     34
(1 row)
=&amp;gt; SELECT MINUTE(INTERVAL &amp;#39;35 12:34:03.456789&amp;#39;);
 MINUTE
--------
     34
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: MONTH</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/month/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/month/</guid>
      <description>
        
        
        &lt;p&gt;Returns the month portion of the specified date as an integer.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if thespecified date is a &lt;code&gt;TIMESTAMP&lt;/code&gt;, &lt;code&gt;DATE&lt;/code&gt;, &lt;code&gt;VARCHAR&lt;/code&gt; or &lt;code&gt;INTERVAL&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if the specified date is a&lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;MONTH ( &lt;span class=&#34;code-variable&#34;&gt;date&lt;/span&gt; )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;date&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;The date to process, one of the following data types:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/character-data-types-char-and-varchar/#&#34;&gt;VARCHAR&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/date/#&#34;&gt;DATE&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMP&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamp-time-zone/#&#34;&gt;TIMESTAMPTZ&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/interval/#&#34;&gt;INTERVAL&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;In the following examples, OpenText™ Analytics Database returns the month portion of the specified string. For example, &lt;code&gt;&#39;6-9&#39;&lt;/code&gt; represent September 6.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT MONTH(&amp;#39;6-9&amp;#39;);
 MONTH
-------
     9
(1 row)
=&amp;gt; SELECT MONTH (TIMESTAMP &amp;#39;sep 22, 2011 12:34&amp;#39;);
 MONTH
-------
     9
(1 row)
=&amp;gt; SELECT MONTH(INTERVAL &amp;#39;2-35&amp;#39; year to month);
 MONTH
-------
    11
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: MONTHS_BETWEEN</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/months-between/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/months-between/</guid>
      <description>
        
        
        &lt;p&gt;Returns the number of months between two dates. &lt;code&gt;MONTHS_BETWEEN&lt;/code&gt; can return an integer or a FLOAT:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Integer: The day portions of &lt;em&gt;&lt;code&gt;date1&lt;/code&gt;&lt;/em&gt; and &lt;em&gt;&lt;code&gt;date2&lt;/code&gt;&lt;/em&gt; are the same, and neither date is the last day of the month. &lt;code&gt;MONTHS_BETWEEN&lt;/code&gt; also returns an integer if both dates in &lt;em&gt;&lt;code&gt;date1&lt;/code&gt;&lt;/em&gt; and &lt;em&gt;&lt;code&gt;date2&lt;/code&gt;&lt;/em&gt; are the last days of their respective months. For example, &lt;code&gt;MONTHS_BETWEEN&lt;/code&gt; calculates the difference between April 30 and March 31 as 1 month.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;FLOAT: The day portions of &lt;em&gt;&lt;code&gt;date1&lt;/code&gt;&lt;/em&gt; and &lt;em&gt;&lt;code&gt;date2&lt;/code&gt;&lt;/em&gt; are different and one or both dates are not the last day of their respective months. For example, the difference between April 2 and March 1 is &lt;code&gt;1.03225806451613&lt;/code&gt;. To calculate month fractions, &lt;code&gt;MONTHS_BETWEEN&lt;/code&gt; assumes all months contain 31 days.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;MONTHS_BETWEEN&lt;/code&gt; disregards timestamp time portions.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if both date arguments are of data type &lt;code&gt;TIMESTAMP&lt;/code&gt; or &lt;code&gt;DATE&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if either date is a &lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;MONTHS_BETWEEN ( &lt;span class=&#34;code-variable&#34;&gt;date1&lt;/span&gt; , &lt;span class=&#34;code-variable&#34;&gt;date2&lt;/span&gt; );
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;date1&lt;/code&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;code&gt;date2&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;Specify the dates to evaluate where &lt;em&gt;&lt;code&gt;date1&lt;/code&gt;&lt;/em&gt; and &lt;em&gt;&lt;code&gt;date2&lt;/code&gt;&lt;/em&gt; evaluate to one of the following data types:
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;DATE&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;TIMESTAMP&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If &lt;em&gt;&lt;code&gt;date1&lt;/code&gt;&lt;/em&gt; &amp;lt; &lt;em&gt;&lt;code&gt;date2&lt;/code&gt;&lt;/em&gt;, &lt;code&gt;MONTHS_BETWEEN&lt;/code&gt; returns a negative value.&lt;/p&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;Return the number of months between April 7 2016 and January 7 2015:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT MONTHS_BETWEEN (&amp;#39;04-07-16&amp;#39;::TIMESTAMP, &amp;#39;01-07-15&amp;#39;::TIMESTAMP);
 MONTHS_BETWEEN
----------------
             15
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Return the number of months between March 31 2016 and February 28 2016 (&lt;code&gt;MONTHS_BETWEEN&lt;/code&gt; assumes both months contain 31 days):&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT MONTHS_BETWEEN (&amp;#39;03-31-16&amp;#39;::TIMESTAMP, &amp;#39;02-28-16&amp;#39;::TIMESTAMP);
  MONTHS_BETWEEN
------------------
 1.09677419354839
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Return the number of months between March 31 2016 and February 29 2016:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT MONTHS_BETWEEN (&amp;#39;03-31-16&amp;#39;::TIMESTAMP, &amp;#39;02-29-16&amp;#39;::TIMESTAMP);
 MONTHS_BETWEEN
----------------
              1
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: NEW_TIME</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/new-time/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/new-time/</guid>
      <description>
        
        
        &lt;p&gt;Converts a timestamp value from one time zone to another and returns a TIMESTAMP.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;NEW_TIME( &amp;#39;&lt;span class=&#34;code-variable&#34;&gt;timestamp&lt;/span&gt;&amp;#39; , &amp;#39;&lt;span class=&#34;code-variable&#34;&gt;timezone1&lt;/span&gt;&amp;#39; , &amp;#39;&lt;span class=&#34;code-variable&#34;&gt;timezone2&lt;/span&gt;&amp;#39;)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;timestamp&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;The timestamp to convert, conforms to one of the following formats:
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMP&lt;/a&gt;/&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMPTZ&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/date/#&#34;&gt;DATE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Character string that can be converted to a &lt;code&gt;TIMESTAMP&lt;/code&gt;—for example, &lt;code&gt;May 24, 2012 10:00&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;span class=&#34;code-variable&#34;&gt;timezone1&lt;br /&gt;*`timezone2`*&lt;/span&gt;&lt;/dt&gt;
&lt;dd&gt;Specify the source and target timezones, one of the strings defined in 
&lt;code&gt;/opt/vertica/share/timezonesets&lt;/code&gt;. For example:
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;GMT&lt;/code&gt;: 				Greenwich Mean Time&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;AST&lt;/code&gt; / &lt;code&gt;ADT&lt;/code&gt;: 				Atlantic Standard/Daylight Time&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;EST&lt;/code&gt; / &lt;code&gt;EDT&lt;/code&gt;: 				Eastern Standard/Daylight Time&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;CST&lt;/code&gt; / &lt;code&gt;CDT&lt;/code&gt;: 				Central Standard/Daylight Time&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;MST&lt;/code&gt; / &lt;code&gt;MDT&lt;/code&gt;: 				Mountain Standard/Daylight Time&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;PST&lt;/code&gt; / &lt;code&gt;PDT&lt;/code&gt;: 				Pacific Standard/Daylight Time&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;Convert the specified time from Eastern Standard Time (EST) to Pacific Standard Time (PST):&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT NEW_TIME(&amp;#39;05-24-12 13:48:00&amp;#39;, &amp;#39;EST&amp;#39;, &amp;#39;PST&amp;#39;);
      NEW_TIME
---------------------
 2012-05-24 10:48:00
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Convert 1:00 AM January 2012 from EST to PST:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT NEW_TIME(&amp;#39;01-01-12 01:00:00&amp;#39;, &amp;#39;EST&amp;#39;, &amp;#39;PST&amp;#39;);
      NEW_TIME
---------------------
 2011-12-31 22:00:00
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Convert the current time EST to PST:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
=&amp;gt; SELECT NOW();
              NOW
-------------------------------
 2016-12-09 10:30:36.727307-05
(1 row)

=&amp;gt; SELECT NEW_TIME(&amp;#39;NOW&amp;#39;, &amp;#39;EDT&amp;#39;, &amp;#39;CDT&amp;#39;);
          NEW_TIME
----------------------------
 2016-12-09 09:30:36.727307
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The following example returns the year 45 before the Common Era in Greenwich Mean Time and converts it to Newfoundland Standard Time:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt;  SELECT NEW_TIME(&amp;#39;April 1, 45 BC&amp;#39;, &amp;#39;GMT&amp;#39;, &amp;#39;NST&amp;#39;)::DATE;
   NEW_TIME
---------------
 0045-03-31 BC
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: NEXT_DAY</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/next-day/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/next-day/</guid>
      <description>
        
        
        &lt;p&gt;Returns the date of the first instance of a particular day of the week that follows the specified date.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if thespecified date is a &lt;code&gt;TIMESTAMP&lt;/code&gt;, &lt;code&gt;DATE&lt;/code&gt;, or &lt;code&gt;VARCHAR&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if the specified date is a&lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;NEXT_DAY( &amp;#39;&lt;span class=&#34;code-variable&#34;&gt;date&lt;/span&gt;&amp;#39;, &amp;#39;&lt;span class=&#34;code-variable&#34;&gt;day-string&lt;/span&gt;&amp;#39;)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;date&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;The date to process, one of the following data types:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/character-data-types-char-and-varchar/#&#34;&gt;VARCHAR&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/date/#&#34;&gt;DATE&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMP&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamp-time-zone/#&#34;&gt;TIMESTAMPTZ&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;day-string&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;The day of the week to process, a CHAR or VARCHAR string or character constant. Supply the full English name such as Tuesday, or any conventional abbreviation, such as Tue or Tues. &lt;em&gt;&lt;code&gt;day-string&lt;/code&gt;&lt;/em&gt; is not case sensitive and trailing spaces are ignored.&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;Get the date of the first Monday that follows April 29 2016:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT NEXT_DAY(&amp;#39;4-29-2016&amp;#39;::TIMESTAMP,&amp;#39;Monday&amp;#39;) &amp;#34;NEXT DAY&amp;#34; ;
  NEXT DAY
------------
 2016-05-02
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Get the first Tuesday that follows today:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SELECT NEXT_DAY(CURRENT_TIMESTAMP,&amp;#39;tues&amp;#39;) &amp;#34;NEXT DAY&amp;#34; ;
  NEXT DAY
------------
 2016-05-03
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: NOW [date/time]</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/now-datetime/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/now-datetime/</guid>
      <description>
        
        
        &lt;p&gt;Returns a value of type TIMESTAMP WITH TIME ZONE representing the start of the current transaction. NOW is equivalent to 
&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/functions/data-type-specific-functions/datetime-functions/current-timestamp/#&#34;&gt;CURRENT_TIMESTAMP&lt;/a&gt;&lt;/code&gt; except that it does not accept a precision parameter.&lt;/p&gt;
&lt;p&gt;The return value does not change during the transaction. Thus, multiple calls to &lt;code&gt;CURRENT_TIMESTAMP&lt;/code&gt; within the same transaction return the same timestamp.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;NOW()
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
=&amp;gt; CREATE TABLE t1 (a int, b int);
CREATE TABLE
=&amp;gt; INSERT INTO t1 VALUES (1,2);
 OUTPUT
--------
      1
(1 row)

=&amp;gt; SELECT NOW();
             NOW
------------------------------
 2016-12-09 13:00:08.74685-05
(1 row)

=&amp;gt; INSERT INTO t1 VALUES (3,4);
 OUTPUT
--------
      1
(1 row)

=&amp;gt; SELECT NOW();
             NOW
------------------------------
 2016-12-09 13:00:08.74685-05
(1 row)

=&amp;gt; COMMIT;
COMMIT
dbadmin=&amp;gt; SELECT NOW();
              NOW
-------------------------------
 2016-12-09 13:01:31.420624-05
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: OVERLAPS</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/overlaps/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/overlaps/</guid>
      <description>
        
        
        &lt;p&gt;Evaluates two time periods and returns true when they overlap, false otherwise.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; when &lt;code&gt;TIMESTAMP&lt;/code&gt; and &lt;code&gt;TIMESTAMPTZ&lt;/code&gt; are both used, or when &lt;code&gt;TIMESTAMPTZ&lt;/code&gt; is used with &lt;code&gt;INTERVAL&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; otherwise&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;( &lt;span class=&#34;code-variable&#34;&gt;start&lt;/span&gt;, &lt;span class=&#34;code-variable&#34;&gt;end&lt;/span&gt; ) OVERLAPS ( &lt;span class=&#34;code-variable&#34;&gt;start&lt;/span&gt;, &lt;span class=&#34;code-variable&#34;&gt;end&lt;/span&gt; )
( &lt;span class=&#34;code-variable&#34;&gt;start&lt;/span&gt;, &lt;span class=&#34;code-variable&#34;&gt;interval&lt;/span&gt;) OVERLAPS ( &lt;span class=&#34;code-variable&#34;&gt;start&lt;/span&gt;, &lt;span class=&#34;code-variable&#34;&gt;interval&lt;/span&gt; )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;start&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;code&gt;DATE&lt;/code&gt;, &lt;code&gt;TIME&lt;/code&gt;, or &lt;code&gt;TIMESTAMP&lt;/code&gt;/&lt;code&gt;TIMESTAMPTZ&lt;/code&gt; value that specifies the beginning of a time period.&lt;/dd&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;end&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;code&gt;DATE&lt;/code&gt;, &lt;code&gt;TIME&lt;/code&gt;, or &lt;code&gt;TIMESTAMP&lt;/code&gt;/&lt;code&gt;TIMESTAMPTZ&lt;/code&gt; value that specifies the end of a time period.&lt;/dd&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;interval&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;Value that specifies the length of the time period.&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;Evaluate whether date ranges Feb 16 - Dec 21, 2016 and Oct 10 2008 - Oct 3 2016 overlap:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT (DATE &amp;#39;2016-02-16&amp;#39;, DATE &amp;#39;2016-12-21&amp;#39;) OVERLAPS (DATE &amp;#39;2008-10-30&amp;#39;, DATE &amp;#39;2016-10-30&amp;#39;);
 overlaps
----------
 t
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Evaluate whether date ranges Feb 16 - Dec 21, 2016 and Jan 01 - Oct 30 2008 - Oct 3, 2016 overlap:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT (DATE &amp;#39;2016-02-16&amp;#39;, DATE &amp;#39;2016-12-21&amp;#39;) OVERLAPS (DATE &amp;#39;2008-01-30&amp;#39;, DATE &amp;#39;2008-10-30&amp;#39;);
 overlaps
----------
 f
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Evaluate whether date range Feb 02 2016 + 1 week overlaps with date range Oct 16 2016 - 8 months:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT (DATE &amp;#39;2016-02-16&amp;#39;, INTERVAL &amp;#39;1 week&amp;#39;) OVERLAPS (DATE &amp;#39;2016-10-16&amp;#39;, INTERVAL &amp;#39;-8 months&amp;#39;);
 overlaps
----------
 t
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: QUARTER</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/quarter/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/quarter/</guid>
      <description>
        
        
        &lt;p&gt;Returns calendar quarter of the specified date as an integer, where the January-March quarter is 1.&lt;/p&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;QUARTER ( &lt;span class=&#34;code-variable&#34;&gt;date&lt;/span&gt; )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if thespecified date is a &lt;code&gt;TIMESTAMP&lt;/code&gt;, &lt;code&gt;DATE&lt;/code&gt;, or &lt;code&gt;VARCHAR&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if the specified date is a&lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;date&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;The date to process, one of the following data types:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/character-data-types-char-and-varchar/#&#34;&gt;VARCHAR&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/date/#&#34;&gt;DATE&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMP&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamp-time-zone/#&#34;&gt;TIMESTAMPTZ&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT QUARTER (TIMESTAMP &amp;#39;sep 22, 2011 12:34&amp;#39;);
 QUARTER
---------
       3
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: ROUND</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/round/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/round/</guid>
      <description>
        
        
        &lt;p&gt;Rounds the specified date or time. If you omit the precision argument, &lt;code&gt;ROUND&lt;/code&gt; rounds to day (&lt;code&gt;DD&lt;/code&gt;) precision.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if thetarget date is a &lt;code&gt;TIMESTAMP&lt;/code&gt; or &lt;code&gt;DATE&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if the target date is a&lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;ROUND( &lt;span class=&#34;code-variable&#34;&gt;&lt;span class=&#34;code-variable&#34;&gt;rounding-target&lt;/span&gt;&lt;/span&gt;[, &amp;#39;&lt;span class=&#34;code-variable&#34;&gt;precision&lt;/span&gt;&amp;#39;] )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;*&lt;/code&gt;rounding-target&lt;code&gt;*&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;An expression that evaluates to one of the following data types:
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/date/#&#34;&gt;DATE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMP/TIMESTAMPTZ&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMPTZ&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;precision&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;A string constant that specifies precision for the rounded value, one of the following:
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Century&lt;/strong&gt;: &lt;code&gt;CC&lt;/code&gt; | &lt;code&gt;SCC&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Year&lt;/strong&gt;: &lt;code&gt;SYYY&lt;/code&gt; | &lt;code&gt;YYYY&lt;/code&gt; | &lt;code&gt;YEAR&lt;/code&gt; | &lt;code&gt;YYY&lt;/code&gt; | &lt;code&gt;YY&lt;/code&gt; | &lt;code&gt;Y&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;ISO Year&lt;/strong&gt;: &lt;code&gt;IYYY&lt;/code&gt; | &lt;code&gt;IYY&lt;/code&gt; | &lt;code&gt;IY&lt;/code&gt; | &lt;code&gt;I&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Quarter&lt;/strong&gt;: &lt;code&gt;Q&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Month&lt;/strong&gt;: &lt;code&gt;MONTH&lt;/code&gt; | &lt;code&gt;MON&lt;/code&gt; | &lt;code&gt;MM&lt;/code&gt; | &lt;code&gt;RM&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Same weekday as first day of year&lt;/strong&gt;: &lt;code&gt;WW&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Same weekday as first day of ISO year&lt;/strong&gt;: &lt;code&gt;IW&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Same weekday as first day of month&lt;/strong&gt;: &lt;code&gt;W&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Day&lt;/strong&gt; (default): &lt;code&gt;DDD&lt;/code&gt; | &lt;code&gt;DD&lt;/code&gt; | &lt;code&gt;J&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;First weekday&lt;/strong&gt;: &lt;code&gt;DAY&lt;/code&gt; | &lt;code&gt;DY&lt;/code&gt; | &lt;code&gt;D&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Hour&lt;/strong&gt;: &lt;code&gt;HH&lt;/code&gt; | &lt;code&gt;HH12&lt;/code&gt; | &lt;code&gt;HH24&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Minute&lt;/strong&gt;: &lt;code&gt;MI&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Second&lt;/strong&gt;: &lt;code&gt;SS&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;alert admonition note&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Note&lt;/h4&gt;

Hour, minute, and second rounding is not supported by &lt;code&gt;DATE&lt;/code&gt; expressions.

&lt;/div&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;Round to the nearest hour:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ROUND(CURRENT_TIMESTAMP, &amp;#39;HH&amp;#39;);
        ROUND
---------------------
 2016-04-28 15:00:00
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Round to the nearest month:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ROUND(&amp;#39;9-22-2011 12:34:00&amp;#39;::TIMESTAMP, &amp;#39;MM&amp;#39;);
        ROUND
---------------------
 2011-10-01 00:00:00
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/data-type-specific-functions/datetime-functions/timestamp-round/#&#34;&gt;TIMESTAMP_ROUND&lt;/a&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: SECOND</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/second/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/second/</guid>
      <description>
        
        
        &lt;p&gt;Returns the seconds portion of the specified date as an integer.&lt;/p&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SECOND ( &lt;span class=&#34;code-variable&#34;&gt;date&lt;/span&gt; )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt;, except for TIMESTAMPTZ arguments where it is &lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;stable&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;date&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;The date to process, one of the following data types:
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/character-data-types-char-and-varchar/#&#34;&gt;VARCHAR&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMP&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamp-time-zone/#&#34;&gt;TIMESTAMPTZ&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/interval/#&#34;&gt;INTERVAL&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT SECOND (&amp;#39;23:34:03.456789&amp;#39;);
 SECOND
--------
      3
(1 row)
=&amp;gt; SELECT SECOND (TIMESTAMP &amp;#39;sep 22, 2011 12:34&amp;#39;);
 SECOND
--------
      0
(1 row)
=&amp;gt; SELECT SECOND (INTERVAL &amp;#39;35 12:34:03.456789&amp;#39;);
 SECOND
--------
      3
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: STATEMENT_TIMESTAMP</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/statement-timestamp/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/statement-timestamp/</guid>
      <description>
        
        
        &lt;p&gt;Similar to 
&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/functions/data-type-specific-functions/datetime-functions/transaction-timestamp/#&#34;&gt;TRANSACTION_TIMESTAMP&lt;/a&gt;&lt;/code&gt;, returns a value of type &lt;code&gt;TIMESTAMP WITH TIME ZONE&lt;/code&gt; that represents the start of the current statement.&lt;/p&gt;
&lt;p&gt;The return value does not change during statement execution. Thus, different stages of statement execution always have the same timestamp.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;STATEMENT_TIMESTAMP()
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT foo, bar FROM (SELECT STATEMENT_TIMESTAMP() AS foo)foo, (SELECT STATEMENT_TIMESTAMP() as bar)bar;
              foo              |              bar
-------------------------------+-------------------------------
 2016-12-07 14:55:51.543988-05 | 2016-12-07 14:55:51.543988-05
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/functions/data-type-specific-functions/datetime-functions/clock-timestamp/#&#34;&gt;CLOCK_TIMESTAMP&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/functions/data-type-specific-functions/datetime-functions/transaction-timestamp/#&#34;&gt;TRANSACTION_TIMESTAMP&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: SYSDATE</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/sysdate/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/sysdate/</guid>
      <description>
        
        
        &lt;p&gt;Returns the current statement&#39;s start date and time as a &lt;code&gt;TIMESTAMP&lt;/code&gt; value. This function is identical to 
&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/functions/data-type-specific-functions/datetime-functions/getdate/#&#34;&gt;GETDATE&lt;/a&gt;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;SYSDATE&lt;/code&gt; uses the date and time supplied by the operating system on the server to which you are connected, which is the same across all servers. Internally, &lt;code&gt;GETDATE&lt;/code&gt; converts 
&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/functions/data-type-specific-functions/datetime-functions/statement-timestamp/#&#34;&gt;STATEMENT_TIMESTAMP&lt;/a&gt;&lt;/code&gt; from &lt;code&gt;TIMESTAMPTZ&lt;/code&gt; to &lt;code&gt;TIMESTAMP&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SYSDATE()
&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&#34;alert admonition note&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Note&lt;/h4&gt;

You can call this function with no parentheses.

&lt;/div&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT SYSDATE;
          sysdate
----------------------------
 2016-12-12 06:11:10.699642
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;a href=&#34;../../../../../en/sql-reference/language-elements/expressions/datetime-expressions/#&#34;&gt;Date/time expressions&lt;/a&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: TIME_SLICE</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/time-slice/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/time-slice/</guid>
      <description>
        
        
        &lt;p&gt;Aggregates data by different fixed-time intervals and returns a rounded-up input &lt;code&gt;TIMESTAMP&lt;/code&gt; value to a value that corresponds with the start or end of the time slice interval.&lt;/p&gt;
&lt;p&gt;Given an input &lt;code&gt;TIMESTAMP&lt;/code&gt; value such as &lt;code&gt;2000-10-28 00:00:01&lt;/code&gt;, the start time of a 3-second time slice interval is &lt;code&gt;2000-10-28 00:00:00&lt;/code&gt;, and the end time of the same time slice is &lt;code&gt;2000-10-28 00:00:03&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;TIME_SLICE( &lt;span class=&#34;code-variable&#34;&gt;expression&lt;/span&gt;, &lt;span class=&#34;code-variable&#34;&gt;slice-length&lt;/span&gt; [, &amp;#39;&lt;span class=&#34;code-variable&#34;&gt;time-unit&lt;/span&gt;&amp;#39; [, &lt;span class=&#34;code-variable&#34;&gt;&#39;start-or-end&#39; &lt;/span&gt;] ] )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;expression&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;One of the following:
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Column of type &lt;code&gt;TIMESTAMP&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;String constant that can be parsed into a &lt;code&gt;TIMESTAMP&lt;/code&gt; value. For example:&lt;/p&gt;
&lt;p&gt;&#39;2004-10-19 10:23:54&#39;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;OpenText™ Analytics Database evaluates &lt;em&gt;&lt;code&gt;expression&lt;/code&gt;&lt;/em&gt; on each row.&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;slice-length&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;A positive integer that specifies the slice length.&lt;/dd&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;time-unit&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;Time unit of the slice, one of the following:
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;HOUR&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;MINUTE&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;SECOND&lt;/code&gt; (default)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;MILLISECOND&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;MICROSECOND&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;start-or-end &lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;Specifies whether the returned value corresponds to the start or end time with one of the following strings:
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;START&lt;/code&gt; (default)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;END&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;alert admonition note&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Note&lt;/h4&gt;

This parameter can be included only if you also supply a non-null &lt;em&gt;&lt;code&gt;time-unit&lt;/code&gt;&lt;/em&gt; argument.

&lt;/div&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;null-argument-handling&#34;&gt;Null argument handling&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;TIME_SLICE&lt;/code&gt; handles null arguments as follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;TIME_SLICE&lt;/code&gt; returns an error when any one of &lt;em&gt;&lt;code&gt;slice-length&lt;/code&gt;&lt;/em&gt;, &lt;em&gt;&lt;code&gt;time-unit&lt;/code&gt;&lt;/em&gt;, or &lt;em&gt;&lt;code&gt;start-or-end&lt;/code&gt;&lt;/em&gt; parameters is null.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If &lt;em&gt;&lt;code&gt;expression&lt;/code&gt;&lt;/em&gt; is null and &lt;em&gt;&lt;code&gt;*&lt;/code&gt;slice-length&lt;code&gt;*, *&lt;/code&gt;time-unit&lt;code&gt;*, or *&lt;/code&gt;start-or-end&lt;code&gt;*&lt;/code&gt;&lt;/em&gt; contain legal values, &lt;code&gt;TIME_SLICE&lt;/code&gt; returns a NULL value instead of an error.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;usage&#34;&gt;Usage&lt;/h2&gt;
&lt;p&gt;The following command returns the (default) start time of a 3-second time slice:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT TIME_SLICE(&amp;#39;2009-09-19 00:00:01&amp;#39;, 3);
     TIME_SLICE
---------------------
 2009-09-19 00:00:00
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The following command returns the end time of a 3-second time slice:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT TIME_SLICE(&amp;#39;2009-09-19 00:00:01&amp;#39;, 3, &amp;#39;SECOND&amp;#39;, &amp;#39;END&amp;#39;);
     TIME_SLICE
---------------------
 2009-09-19 00:00:03
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This command returns results in milliseconds, using a 3-second time slice:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT TIME_SLICE(&amp;#39;2009-09-19 00:00:01&amp;#39;, 3, &amp;#39;ms&amp;#39;);
       TIME_SLICE
-------------------------
 2009-09-19 00:00:00.999

(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This command returns results in microseconds, using a 9-second time slice:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT TIME_SLICE(&amp;#39;2009-09-19 00:00:01&amp;#39;, 3, &amp;#39;us&amp;#39;);
         TIME_SLICE
----------------------------
 2009-09-19 00:00:00.999999
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The next example uses a 3-second interval with an input value of &#39;00:00:01&#39;. To focus specifically on seconds, the example omits date, though all values are implied as being part of the timestamp with a given input of &lt;code&gt;&#39;00:00:01&#39;&lt;/code&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&#39;00:00:&lt;strong&gt;00&lt;/strong&gt;&#39; is the start of the 3-second time slice&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&#39;00:00:&lt;strong&gt;03&lt;/strong&gt;&#39; is the end of the 3-second time slice.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&#39;00:00:03&#39; is also the start of the &lt;em&gt;&lt;code&gt;second&lt;/code&gt;&lt;/em&gt; 3-second time slice. In time slice boundaries, the end value of a time slice does not belong to that time slice; it starts the next one.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;When the time slice interval is not a factor of 60 seconds, such as a given slice length of 9 in the following example, the slice does not always start or end on 00 seconds:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT TIME_SLICE(&amp;#39;2009-02-14 20:13:01&amp;#39;, 9);
     TIME_SLICE
---------------------
 2009-02-14 20:12:54
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This is expected behavior, as the following properties are true for all time slices:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Equal in length&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Consecutive (no gaps between them)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Non-overlapping&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;To force the above example (&#39;2009-02-14 20:13:01&#39;) to start at &#39;2009-02-14 20:13:00&#39;, adjust the output timestamp values so that the remainder of 54 counts up to 60:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT TIME_SLICE(&amp;#39;2009-02-14 20:13:01&amp;#39;, 9 )+&amp;#39;6 seconds&amp;#39;::INTERVAL AS time;
        time
---------------------
 2009-02-14 20:13:00
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Alternatively, you could use a different slice length, which is divisible by 60, such as 5:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT TIME_SLICE(&amp;#39;2009-02-14 20:13:01&amp;#39;, 5);
     TIME_SLICE
---------------------
 2009-02-14 20:13:00
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;A TIMESTAMPTZ value is implicitly cast to TIMESTAMP. For example, the following two statements have the same effect.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT TIME_SLICE(&amp;#39;2009-09-23 11:12:01&amp;#39;::timestamptz, 3);
     TIME_SLICE
---------------------
 2009-09-23 11:12:00
(1 row)


=&amp;gt; SELECT TIME_SLICE(&amp;#39;2009-09-23 11:12:01&amp;#39;::timestamptz::timestamp, 3);

     TIME_SLICE
---------------------
 2009-09-23 11:12:00
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;You can use the SQL analytic functions 
&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/functions/analytic-functions/first-value-analytic/#&#34;&gt;FIRST_VALUE&lt;/a&gt;&lt;/code&gt; and 
&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/functions/analytic-functions/last-value-analytic/#&#34;&gt;LAST_VALUE&lt;/a&gt;&lt;/code&gt; to find the first/last price within each time slice group (set of rows belonging to the same time slice). This structure can be useful if you want to sample input data by choosing one row from each time slice group.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT date_key, transaction_time, sales_dollar_amount,TIME_SLICE(DATE &amp;#39;2000-01-01&amp;#39; + date_key + transaction_time, 3),
FIRST_VALUE(sales_dollar_amount)
OVER (PARTITION BY TIME_SLICE(DATE &amp;#39;2000-01-01&amp;#39; + date_key + transaction_time, 3)
     ORDER BY DATE &amp;#39;2000-01-01&amp;#39; + date_key + transaction_time) AS first_value
FROM store.store_sales_fact
LIMIT 20;

 date_key | transaction_time | sales_dollar_amount |     time_slice      | first_value
----------+------------------+---------------------+---------------------+-------------
        1 | 00:41:16         |                 164 | 2000-01-02 00:41:15 |         164
        1 | 00:41:33         |                 310 | 2000-01-02 00:41:33 |         310
        1 | 15:32:51         |                 271 | 2000-01-02 15:32:51 |         271
        1 | 15:33:15         |                 419 | 2000-01-02 15:33:15 |         419
        1 | 15:33:44         |                 193 | 2000-01-02 15:33:42 |         193
        1 | 16:36:29         |                 466 | 2000-01-02 16:36:27 |         466
        1 | 16:36:44         |                 250 | 2000-01-02 16:36:42 |         250
        2 | 03:11:28         |                  39 | 2000-01-03 03:11:27 |          39
        3 | 03:55:15         |                 375 | 2000-01-04 03:55:15 |         375
        3 | 11:58:05         |                 369 | 2000-01-04 11:58:03 |         369
        3 | 11:58:24         |                 174 | 2000-01-04 11:58:24 |         174
        3 | 11:58:52         |                 449 | 2000-01-04 11:58:51 |         449
        3 | 19:01:21         |                 201 | 2000-01-04 19:01:21 |         201
        3 | 22:15:05         |                 156 | 2000-01-04 22:15:03 |         156
        4 | 13:36:57         |                -125 | 2000-01-05 13:36:57 |        -125
        4 | 13:37:24         |                -251 | 2000-01-05 13:37:24 |        -251
        4 | 13:37:54         |                 353 | 2000-01-05 13:37:54 |         353
        4 | 13:38:04         |                 426 | 2000-01-05 13:38:03 |         426
        4 | 13:38:31         |                 209 | 2000-01-05 13:38:30 |         209
        5 | 10:21:24         |                 488 | 2000-01-06 10:21:24 |         488
(20 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;code&gt;TIME_SLICE&lt;/code&gt; rounds the transaction time to the 3-second slice length.&lt;/p&gt;
&lt;p&gt;The following example uses the &lt;a href=&#34;../../../../../en/data-analysis/sql-analytics/invoking-analytic-functions/&#34;&gt;analytic (window) OVER clause&lt;/a&gt; to return the last trading price (the last row ordered by TickTime) in each 3-second time slice partition:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT DISTINCT TIME_SLICE(TickTime, 3), LAST_VALUE(price)&lt;span class=&#34;code-input&#34;&gt;OVER (PARTITION BY TIME_SLICE(TickTime, 3)&lt;/span&gt;
ORDER BY TickTime ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING);
&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&#34;alert admonition note&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Note&lt;/h4&gt;

If you omit the windowing clause from an analytic clause, &lt;code&gt;LAST_VALUE&lt;/code&gt; defaults to &lt;code&gt;RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW&lt;/code&gt;. Results can seem non-intuitive, because instead of returning the value from the bottom of the current partition, the function returns the bottom of the &lt;em&gt;&lt;code&gt;window&lt;/code&gt;&lt;/em&gt;, which continues to change along with the current input row that is being processed. For more information, see &lt;a href=&#34;../../../../../en/data-analysis/time-series-analytics/#&#34;&gt;Time series analytics&lt;/a&gt; and &lt;a href=&#34;../../../../../en/data-analysis/sql-analytics/#&#34;&gt;SQL analytics&lt;/a&gt;.

&lt;/div&gt;
&lt;p&gt;In the next example, &lt;code&gt;FIRST_VALUE&lt;/code&gt; is evaluated once for each input record and the data is sorted by ascending values. Use &lt;code&gt;SELECT DISTINCT&lt;/code&gt; to remove the duplicates and return only one output record per &lt;code&gt;TIME_SLICE&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT DISTINCT TIME_SLICE(TickTime, 3), FIRST_VALUE(price)OVER (PARTITION BY TIME_SLICE(TickTime, 3)
ORDER BY TickTime ASC)
FROM tick_store;
     TIME_SLICE      | ?column?
---------------------+----------
 2009-09-21 00:00:06 |    20.00
 2009-09-21 00:00:09 |    30.00
 2009-09-21 00:00:00 |    10.00
(3 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The information output by the above query can also return &lt;code&gt;MIN&lt;/code&gt;, &lt;code&gt;MAX&lt;/code&gt;, and &lt;code&gt;AVG&lt;/code&gt; of the trading prices within each time slice.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT DISTINCT TIME_SLICE(TickTime, 3),FIRST_VALUE(Price) OVER (PARTITION BY TIME_SLICE(TickTime, 3)
ORDER BY TickTime ASC),
  MIN(price) OVER (PARTITION BY TIME_SLICE(TickTime, 3)),
  MAX(price) OVER (PARTITION BY TIME_SLICE(TickTime, 3)),
  AVG(price) OVER (PARTITION BY TIME_SLICE(TickTime, 3))
FROM tick_store;
&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/aggregate-functions/#&#34;&gt;Aggregate functions&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/analytic-functions/first-value-analytic/#&#34;&gt;FIRST_VALUE [analytic]&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/analytic-functions/last-value-analytic/#&#34;&gt;LAST_VALUE [analytic]&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/statements/select/timeseries-clause/#&#34;&gt;TIMESERIES clause&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/aggregate-functions/ts-first-value/#&#34;&gt;TS_FIRST_VALUE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/aggregate-functions/ts-last-value/#&#34;&gt;TS_LAST_VALUE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/admin/configuring-db/config-procedure/using-time-zones-with/#&#34;&gt;Using time zones&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: TIMEOFDAY</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/timeofday/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/timeofday/</guid>
      <description>
        
        
        &lt;p&gt;Returns the wall-clock time as a text string. Function results advance during transactions.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/volatile-functions/&#34; title=&#34;&#34;&gt;Volatile&lt;/a&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;TIMEOFDAY()
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT TIMEOFDAY();
              TIMEOFDAY
-------------------------------------
 Mon Dec 12 08:18:01.022710 2016 EST
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: TIMESTAMP_ROUND</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/timestamp-round/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/timestamp-round/</guid>
      <description>
        
        
        &lt;p&gt;Rounds the specified TIMESTAMP. If you omit the precision argument, &lt;code&gt;TIMESTAMP_ROUND&lt;/code&gt; rounds to day (&lt;code&gt;DD&lt;/code&gt;) precision.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if thetarget date is a &lt;code&gt;TIMESTAMP&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if the target date is a &lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;TIMESTAMP_ROUND ( &lt;span class=&#34;code-variable&#34;&gt;rounding-target&lt;/span&gt;[, &amp;#39;&lt;span class=&#34;code-variable&#34;&gt;precision&lt;/span&gt;&amp;#39;] )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;rounding-target&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;An expression that evaluates to one of the following data types:
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMP/TIMESTAMPTZ&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMPTZ&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;precision&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;A string constant that specifies precision for the rounded value, one of the following:
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Century&lt;/strong&gt;: &lt;code&gt;CC&lt;/code&gt; | &lt;code&gt;SCC&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Year&lt;/strong&gt;: &lt;code&gt;SYYY&lt;/code&gt; | &lt;code&gt;YYYY&lt;/code&gt; | &lt;code&gt;YEAR&lt;/code&gt; | &lt;code&gt;YYY&lt;/code&gt; | &lt;code&gt;YY&lt;/code&gt; | &lt;code&gt;Y&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;ISO Year&lt;/strong&gt;: &lt;code&gt;IYYY&lt;/code&gt; | &lt;code&gt;IYY&lt;/code&gt; | &lt;code&gt;IY&lt;/code&gt; | &lt;code&gt;I&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Quarter&lt;/strong&gt;: &lt;code&gt;Q&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Month&lt;/strong&gt;: &lt;code&gt;MONTH&lt;/code&gt; | &lt;code&gt;MON&lt;/code&gt; | &lt;code&gt;MM&lt;/code&gt; | &lt;code&gt;RM&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Same weekday as first day of year&lt;/strong&gt;: &lt;code&gt;WW&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Same weekday as first day of ISO year&lt;/strong&gt;: &lt;code&gt;IW&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Same weekday as first day of month&lt;/strong&gt;: &lt;code&gt;W&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Day&lt;/strong&gt; (default): &lt;code&gt;DDD&lt;/code&gt; | &lt;code&gt;DD&lt;/code&gt; | &lt;code&gt;J&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;First weekday&lt;/strong&gt;: &lt;code&gt;DAY&lt;/code&gt; | &lt;code&gt;DY&lt;/code&gt; | &lt;code&gt;D&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Hour&lt;/strong&gt;: &lt;code&gt;HH&lt;/code&gt; | &lt;code&gt;HH12&lt;/code&gt; | &lt;code&gt;HH24&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Minute&lt;/strong&gt;: &lt;code&gt;MI&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Second&lt;/strong&gt;: &lt;code&gt;SS&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;alert admonition note&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Note&lt;/h4&gt;

Hour, minute, and second rounding is not supported by &lt;code&gt;DATE&lt;/code&gt; expressions.

&lt;/div&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;Round to the nearest hour:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT TIMESTAMP_ROUND(CURRENT_TIMESTAMP, &amp;#39;HH&amp;#39;);
        ROUND
---------------------
 2016-04-28 15:00:00
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Round to the nearest month:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT TIMESTAMP_ROUND(&amp;#39;9-22-2011 12:34:00&amp;#39;::TIMESTAMP, &amp;#39;MM&amp;#39;);
        ROUND
---------------------
 2011-10-01 00:00:00
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/data-type-specific-functions/datetime-functions/round/#&#34;&gt;ROUND&lt;/a&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: TIMESTAMP_TRUNC</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/timestamp-trunc/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/timestamp-trunc/</guid>
      <description>
        
        
        &lt;p&gt;Truncates the specified TIMESTAMP. If you omit the precision argument, &lt;code&gt;TIMESTAMP_TRUNC&lt;/code&gt; truncates to day (&lt;code&gt;DD&lt;/code&gt;) precision.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if thetarget date is a &lt;code&gt;TIMESTAMP&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if the target date is a &lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;TIMESTAMP_TRUNC( &lt;span class=&#34;code-variable&#34;&gt;trunc-target&lt;/span&gt;[, &amp;#39;&lt;span class=&#34;code-variable&#34;&gt;precision&lt;/span&gt;&amp;#39;] )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;trunc-target&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;An expression that evaluates to one of the following data types:
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMP/TIMESTAMPTZ&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMPTZ&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;precision&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;A string constant that specifies precision for the truncated value, one of the following:
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Century&lt;/strong&gt;: &lt;code&gt;CC&lt;/code&gt; | &lt;code&gt;SCC&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Year&lt;/strong&gt;: &lt;code&gt;SYYY&lt;/code&gt; | &lt;code&gt;YYYY&lt;/code&gt; | &lt;code&gt;YEAR&lt;/code&gt; | &lt;code&gt;YYY&lt;/code&gt; | &lt;code&gt;YY&lt;/code&gt; | &lt;code&gt;Y&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;ISO Year&lt;/strong&gt;: &lt;code&gt;IYYY&lt;/code&gt; | &lt;code&gt;IYY&lt;/code&gt; | &lt;code&gt;IY&lt;/code&gt; | &lt;code&gt;I&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Quarter&lt;/strong&gt;: &lt;code&gt;Q&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Month&lt;/strong&gt;: &lt;code&gt;MONTH&lt;/code&gt; | &lt;code&gt;MON&lt;/code&gt; | &lt;code&gt;MM&lt;/code&gt; | &lt;code&gt;RM&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Same weekday as first day of year&lt;/strong&gt;: &lt;code&gt;WW&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Same weekday as first day of ISO year&lt;/strong&gt;: &lt;code&gt;IW&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Same weekday as first day of month&lt;/strong&gt;: &lt;code&gt;W&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Day&lt;/strong&gt;: &lt;code&gt;DDD&lt;/code&gt; | &lt;code&gt;DD&lt;/code&gt; | &lt;code&gt;J&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;First weekday&lt;/strong&gt;: &lt;code&gt;DAY&lt;/code&gt; | &lt;code&gt;DY&lt;/code&gt; | &lt;code&gt;D&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Hour&lt;/strong&gt;: &lt;code&gt;HH&lt;/code&gt; | &lt;code&gt;HH12&lt;/code&gt; | &lt;code&gt;HH24&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Minute&lt;/strong&gt;: &lt;code&gt;MI&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Second&lt;/strong&gt;: &lt;code&gt;SS&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;alert admonition note&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Note&lt;/h4&gt;

Hour, minute, and second truncating is not supported by &lt;code&gt;DATE&lt;/code&gt; expressions.

&lt;/div&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;Truncate to the current hour:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT TIMESTAMP_TRUNC(CURRENT_TIMESTAMP, &amp;#39;HH&amp;#39;);
   TIMESTAMP_TRUNC
---------------------
 2016-04-29 08:00:00
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Truncate to the month:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT TIMESTAMP_TRUNC(&amp;#39;9-22-2011 12:34:00&amp;#39;::TIMESTAMP, &amp;#39;MM&amp;#39;);
   TIMESTAMP_TRUNC
---------------------
 2011-09-01 00:00:00
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/data-type-specific-functions/datetime-functions/trunc/#&#34;&gt;TRUNC&lt;/a&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: TIMESTAMPADD</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/timestampadd/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/timestampadd/</guid>
      <description>
        
        
        &lt;p&gt;Adds the specified number of intervals to a TIMESTAMP or TIMESTAMPTZ value and returns a result of the same data type.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if the input date is a &lt;code&gt;TIMESTAMP&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if the input date is a &lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;TIMESTAMPADD ( &lt;span class=&#34;code-variable&#34;&gt;datepart&lt;/span&gt;, &lt;span class=&#34;code-variable&#34;&gt;count&lt;/span&gt;, &lt;span class=&#34;code-variable&#34;&gt;start-date&lt;/span&gt; );
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;datepart&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;Specifies the type of time intervals that &lt;code&gt;TIMESTAMPADD&lt;/code&gt; adds to the specified start date. If &lt;em&gt;&lt;code&gt;datepart&lt;/code&gt;&lt;/em&gt; is an expression, it must be enclosed in parentheses:
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;TIMESTAMPADD((&lt;span class=&#34;code-variable&#34;&gt;expression&lt;/span&gt;), &lt;span class=&#34;code-variable&#34;&gt;&lt;span class=&#34;code-variable&#34;&gt;interval&lt;/span&gt;, &lt;span class=&#34;code-variable&#34;&gt;start&lt;/span&gt;&lt;/span&gt;;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;em&gt;&lt;code&gt;datepart&lt;/code&gt;&lt;/em&gt; must evaluate to one of the following string literals, either quoted or unquoted:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;year&lt;/code&gt; | &lt;code&gt;yy&lt;/code&gt; | &lt;code&gt;yyyy&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;quarter&lt;/code&gt; | &lt;code&gt;qq&lt;/code&gt; | &lt;code&gt;q&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;month&lt;/code&gt; | &lt;code&gt;mm&lt;/code&gt; | &lt;code&gt;m&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;day&lt;/code&gt; | &lt;code&gt;dayofyear&lt;/code&gt; | &lt;code&gt;dd&lt;/code&gt; | &lt;code&gt;d&lt;/code&gt; | &lt;code&gt;dy&lt;/code&gt; | &lt;code&gt;y&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;week&lt;/code&gt; | &lt;code&gt;wk&lt;/code&gt; | &lt;code&gt;ww&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;hour&lt;/code&gt; | &lt;code&gt;hh&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;minute&lt;/code&gt; | &lt;code&gt;mi&lt;/code&gt; | &lt;code&gt;n&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;second&lt;/code&gt; | &lt;code&gt;ss&lt;/code&gt; | &lt;code&gt;s&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;millisecond&lt;/code&gt; | &lt;code&gt;ms&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;microsecond&lt;/code&gt; | &lt;code&gt;mcs&lt;/code&gt; | &lt;code&gt;us&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;count&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;Integer or integer expression that specifies the number of &lt;em&gt;&lt;code&gt;datepart&lt;/code&gt;&lt;/em&gt; intervals to add to &lt;em&gt;&lt;code&gt;start-date&lt;/code&gt;&lt;/em&gt;.&lt;/dd&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;start-date&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;TIMESTAMP or TIMESTAMPTZ value.&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;Add two months to the current date:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT CURRENT_TIMESTAMP AS Today;
           Today
-------------------------------
 2016-05-02 06:56:57.923045-04
(1 row)

=&amp;gt; SELECT TIMESTAMPADD (MONTH, 2, (CURRENT_TIMESTAMP)) AS TodayPlusTwoMonths;;
      TodayPlusTwoMonths
-------------------------------
 2016-07-02 06:56:57.923045-04
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Add 14 days to the beginning of the current month:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT TIMESTAMPADD (DD, 14, (SELECT TRUNC((CURRENT_TIMESTAMP), &amp;#39;MM&amp;#39;)));
    timestampadd
---------------------
 2016-05-15 00:00:00
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: TIMESTAMPDIFF</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/timestampdiff/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/timestampdiff/</guid>
      <description>
        
        
        &lt;p&gt;Returns the time span between two TIMESTAMP or TIMESTAMPTZ values, in the intervals specified. &lt;code&gt;TIMESTAMPDIFF&lt;/code&gt; excludes the start date in its calculation.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if start and end dates are &lt;code&gt;TIMESTAMP&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if start and end dates are &lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;TIMESTAMPDIFF ( &lt;span class=&#34;code-variable&#34;&gt;datepart&lt;/span&gt;, &lt;span class=&#34;code-variable&#34;&gt;start&lt;/span&gt;, &lt;span class=&#34;code-variable&#34;&gt;end&lt;/span&gt; );
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;datepart&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;Specifies the type of date or time intervals that &lt;code&gt;TIMESTAMPDIFF&lt;/code&gt; returns. If &lt;em&gt;&lt;code&gt;datepart&lt;/code&gt;&lt;/em&gt; is an expression, it must be enclosed in parentheses:
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;TIMESTAMPDIFF((&lt;span class=&#34;code-variable&#34;&gt;expression&lt;/span&gt;), &lt;span class=&#34;code-variable&#34;&gt;start&lt;/span&gt;, &lt;span class=&#34;code-variable&#34;&gt;end&lt;/span&gt; );
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;em&gt;&lt;code&gt;datepart&lt;/code&gt;&lt;/em&gt; must evaluate to one of the following string literals, either quoted or unquoted:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;year&lt;/code&gt; | &lt;code&gt;yy&lt;/code&gt; | &lt;code&gt;yyyy&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;quarter&lt;/code&gt; | &lt;code&gt;qq&lt;/code&gt; | &lt;code&gt;q&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;month&lt;/code&gt; | &lt;code&gt;mm&lt;/code&gt; | &lt;code&gt;m&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;day&lt;/code&gt; | &lt;code&gt;dayofyear&lt;/code&gt; | &lt;code&gt;dd&lt;/code&gt; | &lt;code&gt;d&lt;/code&gt; | &lt;code&gt;dy&lt;/code&gt; | &lt;code&gt;y&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;week&lt;/code&gt; | &lt;code&gt;wk&lt;/code&gt; | &lt;code&gt;ww&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;hour&lt;/code&gt; | &lt;code&gt;hh&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;minute&lt;/code&gt; | &lt;code&gt;mi&lt;/code&gt; | &lt;code&gt;n&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;second&lt;/code&gt; | &lt;code&gt;ss&lt;/code&gt; | &lt;code&gt;s&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;millisecond&lt;/code&gt; | &lt;code&gt;ms&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;microsecond&lt;/code&gt; | &lt;code&gt;mcs&lt;/code&gt; | &lt;code&gt;us&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;start&lt;/code&gt;&lt;/em&gt;&lt;code&gt;, &lt;/code&gt;&lt;em&gt;&lt;code&gt;end&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;Specify the start and end dates, where &lt;em&gt;&lt;code&gt;start&lt;/code&gt;&lt;/em&gt; and &lt;em&gt;&lt;code&gt;end&lt;/code&gt;&lt;/em&gt; evaluate to one of the following data types:
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMP/TIMESTAMPTZ&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If &lt;em&gt;&lt;code&gt;end&lt;/code&gt;&lt;/em&gt; &amp;lt; &lt;em&gt;&lt;code&gt;start&lt;/code&gt;&lt;/em&gt;, &lt;code&gt;TIMESTAMPDIFF&lt;/code&gt; returns a negative value.&lt;/p&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;date-part-intervals&#34;&gt;Date part intervals&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;TIMESTAMPDIFF&lt;/code&gt; uses the &lt;em&gt;&lt;code&gt;datepart&lt;/code&gt;&lt;/em&gt; argument to calculate the number of intervals between two dates, rather than the actual amount of time between them. For detailed information, see 
&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/functions/data-type-specific-functions/datetime-functions/datediff/#&#34;&gt;DATEDIFF&lt;/a&gt;&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT TIMESTAMPDIFF (YEAR,&amp;#39;1-1-2006 12:34:00&amp;#39;, &amp;#39;1-1-2008 12:34:00&amp;#39;);
 timestampdiff
---------------
             2
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/functions/data-type-specific-functions/datetime-functions/datediff/#&#34;&gt;DATEDIFF&lt;/a&gt;&lt;/code&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: TRANSACTION_TIMESTAMP</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/transaction-timestamp/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/transaction-timestamp/</guid>
      <description>
        
        
        &lt;p&gt;Returns a value of type 
&lt;code&gt;`TIME WITH TIMEZONE`&lt;/code&gt; that represents the start of the current transaction.&lt;/p&gt;
&lt;p&gt;The return value does not change during the transaction. Thus, multiple calls to &lt;code&gt;TRANSACTION_TIMESTAMP&lt;/code&gt; within the same transaction return the same timestamp.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;TRANSACTION_TIMESTAMP&lt;/code&gt; is equivalent to 
&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/functions/data-type-specific-functions/datetime-functions/current-timestamp/#&#34;&gt;CURRENT_TIMESTAMP&lt;/a&gt;&lt;/code&gt;, except it does not accept a precision parameter.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;TRANSACTION_TIMESTAMP()
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT foo, bar FROM (SELECT TRANSACTION_TIMESTAMP() AS foo)foo, (SELECT TRANSACTION_TIMESTAMP() as bar)bar;
              foo              |              bar
-------------------------------+-------------------------------
 2016-12-12 08:18:00.988528-05 | 2016-12-12 08:18:00.988528-05
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/functions/data-type-specific-functions/datetime-functions/clock-timestamp/#&#34;&gt;CLOCK_TIMESTAMP&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/functions/data-type-specific-functions/datetime-functions/statement-timestamp/#&#34;&gt;STATEMENT_TIMESTAMP&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: TRUNC</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/trunc/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/trunc/</guid>
      <description>
        
        
        &lt;p&gt;Truncates the specified date or time. If you omit the precision argument, &lt;code&gt;TRUNC&lt;/code&gt; truncates to day (&lt;code&gt;DD&lt;/code&gt;) precision.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if thetarget date is a &lt;code&gt;TIMESTAMP&lt;/code&gt; or &lt;code&gt;DATE&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if the target date is a&lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;TRUNC( &lt;span class=&#34;code-variable&#34;&gt;trunc-target&lt;/span&gt;[, &amp;#39;&lt;span class=&#34;code-variable&#34;&gt;precision&lt;/span&gt;&amp;#39;] )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;*&lt;/code&gt;trunc-target&lt;code&gt;*&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;An expression that evaluates to one of the following data types:
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/date/#&#34;&gt;DATE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMP/TIMESTAMPTZ&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMPTZ&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;precision&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;A string constant that specifies precision for the truncated value, one of the following:
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Century&lt;/strong&gt;: &lt;code&gt;CC&lt;/code&gt; | &lt;code&gt;SCC&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Year&lt;/strong&gt;: &lt;code&gt;SYYY&lt;/code&gt; | &lt;code&gt;YYYY&lt;/code&gt; | &lt;code&gt;YEAR&lt;/code&gt; | &lt;code&gt;YYY&lt;/code&gt; | &lt;code&gt;YY&lt;/code&gt; | &lt;code&gt;Y&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;ISO Year&lt;/strong&gt;: &lt;code&gt;IYYY&lt;/code&gt; | &lt;code&gt;IYY&lt;/code&gt; | &lt;code&gt;IY&lt;/code&gt; | &lt;code&gt;I&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Quarter&lt;/strong&gt;: &lt;code&gt;Q&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Month&lt;/strong&gt;: &lt;code&gt;MONTH&lt;/code&gt; | &lt;code&gt;MON&lt;/code&gt; | &lt;code&gt;MM&lt;/code&gt; | &lt;code&gt;RM&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Same weekday as first day of year&lt;/strong&gt;: &lt;code&gt;WW&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Same weekday as first day of ISO year&lt;/strong&gt;: &lt;code&gt;IW&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Same weekday as first day of month&lt;/strong&gt;: &lt;code&gt;W&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Day&lt;/strong&gt; (default): &lt;code&gt;DDD&lt;/code&gt; | &lt;code&gt;DD&lt;/code&gt; | &lt;code&gt;J&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;First weekday&lt;/strong&gt;: &lt;code&gt;DAY&lt;/code&gt; | &lt;code&gt;DY&lt;/code&gt; | &lt;code&gt;D&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Hour&lt;/strong&gt;: &lt;code&gt;HH&lt;/code&gt; | &lt;code&gt;HH12&lt;/code&gt; | &lt;code&gt;HH24&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Minute&lt;/strong&gt;: &lt;code&gt;MI&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Second&lt;/strong&gt;: &lt;code&gt;SS&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;alert admonition note&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Note&lt;/h4&gt;

Hour, minute, and second truncating is not supported by &lt;code&gt;DATE&lt;/code&gt; expressions.

&lt;/div&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;Truncate to the current hour:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; =&amp;gt; SELECT TRUNC(CURRENT_TIMESTAMP, &amp;#39;HH&amp;#39;);
        TRUNC
---------------------
 2016-04-29 10:00:00
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Truncate to the month:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT TRUNC(&amp;#39;9-22-2011 12:34:00&amp;#39;::TIMESTAMP, &amp;#39;MM&amp;#39;);
   TIMESTAMP_TRUNC
---------------------
 2011-09-01 00:00:00
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/data-type-specific-functions/datetime-functions/timestamp-trunc/#&#34;&gt;TIMESTAMP_TRUNC&lt;/a&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: WEEK</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/week/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/week/</guid>
      <description>
        
        
        &lt;p&gt;Returns the week of the year for the specified date as an integer, where the first week begins on the first Sunday on or preceding January 1.&lt;/p&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;WEEK ( &lt;span class=&#34;code-variable&#34;&gt;date&lt;/span&gt; )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if thespecified date is a &lt;code&gt;TIMESTAMP&lt;/code&gt;, &lt;code&gt;DATE&lt;/code&gt;, or &lt;code&gt;VARCHAR&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if the specified date is a&lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;date&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;The date to process, one of the following data types:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/character-data-types-char-and-varchar/#&#34;&gt;VARCHAR&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/date/#&#34;&gt;DATE&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMP&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamp-time-zone/#&#34;&gt;TIMESTAMPTZ&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;January 2 is on Saturday, so &lt;code&gt;WEEK&lt;/code&gt; returns 1:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT WEEK (&amp;#39;1-2-2016&amp;#39;::DATE);
 WEEK
------
    1
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;January 3 is the second Sunday in 2016, so &lt;code&gt;WEEK&lt;/code&gt; returns 2:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT WEEK (&amp;#39;1-3-2016&amp;#39;::DATE);
 WEEK
------
    2
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: WEEK_ISO</title>
      <link>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/week-iso/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/data-type-specific-functions/datetime-functions/week-iso/</guid>
      <description>
        
        
        &lt;p&gt;Returns the week of the year for the specified date as an integer, where the first week starts on Monday and contains January 4. This function conforms with the ISO 8061 standard.&lt;/p&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;WEEK_ISO ( &lt;span class=&#34;code-variable&#34;&gt;date&lt;/span&gt; )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt; if thespecified date is a &lt;code&gt;TIMESTAMP&lt;/code&gt;, &lt;code&gt;DATE&lt;/code&gt;, or &lt;code&gt;VARCHAR&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/stable-functions/&#34; title=&#34;See also Immutable (invariant) functions.&#34;&gt;Stable&lt;/a&gt; if the specified date is a&lt;code&gt;TIMESTAMPTZ&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;date&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;The date to process, one of the following data types:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/character-data-types-char-and-varchar/#&#34;&gt;VARCHAR&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/date/#&#34;&gt;DATE&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamptimestamptz/#&#34;&gt;TIMESTAMP&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/data-types/datetime-data-types/timestamp-time-zone/#&#34;&gt;TIMESTAMPTZ&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;The first week of 2016 begins on Monday January 4:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT WEEK_ISO (&amp;#39;1-4-2016&amp;#39;::DATE);
 WEEK_ISO
----------
        1
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;January 3 2016 returns week 53 of the previous year (2015):&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT WEEK_ISO (&amp;#39;1-3-2016&amp;#39;::DATE);
 WEEK_ISO
----------
       53
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In 2015, January 4 is on Sunday, so the first week of 2015 begins on the preceding Monday (December 29 2014):&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT WEEK_ISO (&amp;#39;12-29-2014&amp;#39;::DATE);
 WEEK_ISO
----------
        1
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
  </channel>
</rss>
