doc-exports/docs/dli/sqlreference/dli_08_0066.html
Su, Xiaomeng 76a5b1ee83 dli_sqlreference_20240227
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
Co-committed-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
2024-03-27 22:02:33 +00:00

271 lines
36 KiB
HTML

<a name="dli_08_0066"></a><a name="dli_08_0066"></a>
<h1 class="topictitle1">Overview</h1>
<div id="body8662426"><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a4eb9a9b304ea448e951ef2c47f18f371"><a href="#dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_t47047d4480284fb3becd7b6d04352ec3">Table 1</a> lists the date functions supported by DLI.</p>
<div class="tablenoborder"><a name="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_t47047d4480284fb3becd7b6d04352ec3"></a><a name="en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_t47047d4480284fb3becd7b6d04352ec3"></a><table cellpadding="4" cellspacing="0" summary="" id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_t47047d4480284fb3becd7b6d04352ec3" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Date/time functions</caption><thead align="left"><tr id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_r45aca931c8c54044afdb6da9d6f15edf"><th align="left" class="cellrowborder" valign="top" width="32.62501443584709%" id="mcps1.3.2.2.4.1.1"><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_abfe0d47e35bc4affa014a47155c9bb56">Syntax</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="7.991684952072989%" id="mcps1.3.2.2.4.1.2"><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_ac683ec8a51644d5594e147e17be71eb8">Value Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="59.38330061207993%" id="mcps1.3.2.2.4.1.3"><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a511f207accc748b390d97221bc2d70b5">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="dli_08_0066__en-us_topic_0000001701650265_row1429814359148"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_afb83d7c7b9334cf2b11b865d58efa499">add_months(string start_date, int num_months)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a2f1bd2071672406ab589aba4133eebb4">STRING</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a1642aa5d8e864b3d915cef0d6c8597e4">Returns the date that is <strong id="dli_08_0066__en-us_topic_0000001701650265_b051216214201">num_months</strong> after <strong id="dli_08_0066__en-us_topic_0000001701650265_b12512182192014">start_date</strong>.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_row35733411146"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_afa59bb874c244574a30ca53de11a63f2">current_date()</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a7e7ce2f647c24feba2b6629052cedc9c">DATE</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_ab669de3fa3df4fb4aab7ea6693975c4e">Returns the current date, for example, <strong id="dli_08_0066__en-us_topic_0000001701650265_b104361228327">2016-07-04</strong>.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_row957394111418"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a99f93209d7aa474190e63530bf8bdbdf">current_timestamp()</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a94326b7d07134d81bcee314519760e97">TIMESTAMP</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a8578a45068384755a95141de8f4e736b">Returns the current time, for example, <strong id="dli_08_0066__en-us_topic_0000001701650265_b29356142328">2016-07-04 11:18:11.685</strong>.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_row5574154116144"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_aa08552c102b74c03b4b726cdf735865d">date_add(string startdate, int days)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_aed2da6b794fc4ffd94ee573f283a00eb">STRING or DATE</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0093946912_afeff16082dcc4a8fa0f9a0af2f199a25">Adds a number of days to a date.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_row5574174117146"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p19234451754">dateadd(string date, bigint delta, string datepart)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p62353518515">STRING or DATE</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_p2900623151711">Changes a date based on <strong id="dli_08_0066__en-us_topic_0000001701650265_b11354143865113">datepart</strong> and <strong id="dli_08_0066__en-us_topic_0000001701650265_b15705340205116">delta</strong>.</p>
<p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p19665451151912"><strong id="dli_08_0066__en-us_topic_0000001701650265_b18470161716342">date</strong>: This parameter is mandatory. Date value, which is of the STRING type.</p>
<p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p46651351101918">The time format is <strong id="dli_08_0066__en-us_topic_0000001701650265_b125031259153411">yyyy-mm-dd hh:mi:ss</strong>, for example, <strong id="dli_08_0066__en-us_topic_0000001701650265_b1450319593348">2021-08-28 00:00:00</strong>.</p>
<p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p1161112457207"><strong id="dli_08_0066__en-us_topic_0000001701650265_b1689110815355">delta</strong>: This parameter is mandatory. Adjustment amplitude, which is of the BIGINT type.</p>
<p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p1160412121217"><strong id="dli_08_0066__en-us_topic_0000001701650265_b14324161355211">datepart</strong>: Adjustment unit, which is a constant of the STRING type. This parameter is mandatory.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_row145748412148"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_ae4c54c78f1be4f9d807fa0dd23313ada">date_sub(string startdate, int days)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_aa26cf72fbd2f4f5b82b7809cea98adf4">STRING</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a0ee34b2eff2e4e95a9e5dbfa9e737a7e">Subtracts a number of days from a date.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_row1574144110143"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_p11579521144410">date_format(string date, string format)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_af8f60877baca4d0db4c4058d249f7b33">STRING</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_p1138919347437">Converts a date into a string based on the format specified by <strong id="dli_08_0066__en-us_topic_0000001701650265_b65031227174915">format</strong>.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_row10574741191414"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_p547514514720">datediff(string date1, string date2)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a7cdc847901c14491834cb3f16e7af573">BIGINT</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_p990811211817">Calculates the difference between <strong id="dli_08_0066__en-us_topic_0000001701650265_b1955419574499">date1</strong> and <strong id="dli_08_0066__en-us_topic_0000001701650265_b64749598498">date2</strong>.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_row1315612202115"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p87682411661">datediff1(string date1, string date2, string datepart)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p77681941567">BIGINT</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_p15631228155111">Calculates the difference between <strong id="dli_08_0066__en-us_topic_0000001701650265_b399919311528">date1</strong> and <strong id="dli_08_0066__en-us_topic_0000001701650265_b176933336526">date2</strong> and returns the difference in a specified datepart.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_row161519128213"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p1937913711714">datepart (string date, string datepart)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p14379337077">BIGINT</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p7379103717713">Returns the value of the field that meets a specified time unit in the date.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_row3168122216"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p203958266310">datetrunc (string date, string datepart)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p1128610428820">STRING</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_p84498569314">Calculates the date otained through the truncation of a specified date based on a specified datepart.</p>
<p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p1128612421486"><strong id="dli_08_0066__en-us_topic_0000001701650265_b4713155142213">date</strong>: The value is in the <strong id="dli_08_0066__en-us_topic_0000001701650265_b177132512218">yyyy-mm-dd</strong> or <strong id="dli_08_0066__en-us_topic_0000001701650265_b1271417592210">yyyy-mm-dd hh:mi:ss</strong> format. This parameter is mandatory.</p>
<p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p72841816172712"><strong id="dli_08_0066__en-us_topic_0000001701650265_b9401029192216">datepart</strong>: Supported date format, which is a STRING constant. This parameter is mandatory.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_row716201217214"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_afd6704524c1d46d5911bc8b4504fd1e0">day(string date), dayofmonth(string date)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a7f8621c3219b42529a67afef8734ca50">INT</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_aa9dc9bda082345fa8d4ef02752742421">Returns the date of a specified time.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_row181612126214"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_p6309114020312">from_unixtime(bigint unixtime)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_ad5e3f4d7c2c940b99876d5cf1572a69c">STRING</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p7338101202810">Converts a timestamp to a time, in <strong id="dli_08_0066__en-us_topic_0000001701650265_b1551011389271">yyyy-MM-dd HH:mm:ss</strong> or <strong id="dli_08_0066__en-us_topic_0000001701650265_b1723164419279">yyyyMMddHHmmss.uuuuuu</strong> format.</p>
<p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a95bd4e7b181542f78eb78e1a62fab5e8">For example, <strong id="dli_08_0066__en-us_topic_0000001701650265_b12496125217289">select FROM_UNIXTIME(1608135036,'yyyy-MM-dd HH:mm:ss')</strong>.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_row9161112162110"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a736ada8748dd4031bea1119fb23d8064">from_utc_timestamp(string timestamp, string timezone)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a3c070617d47a4352ba8b40f57797a0c0">TIMESTAMP</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a95dbd0426e3c44a1b4e99f1ef0215b90">Converts a UTC timestamp to the corresponding timestamp in a specific time zone.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_row1716181292111"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p265217531487">getdate()</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p8652195312813">STRING</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p465210531384">Obtains the current system time.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_row51610125212"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_aceb04b4f8b184dd1992bb0f0039c0f6a">hour(string date)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a9895a35a31b4497e8f42220de5699897">INT</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_ade44875771284b6499bbe5e944499231">Returns the hour (from 0 to 23) of a specified time.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_row191661210212"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p113209501451">isdate(string date , string format)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p691854561413">BOOLEAN</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p7410154719309"><strong id="dli_08_0066__en-us_topic_0000001701650265_b1271542412316">date</strong>: Date, which is implicitly converted to the STRING type and then used for calculation. This parameter is mandatory.</p>
<p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p485205012304"><strong id="dli_08_0066__en-us_topic_0000001701650265_b1745173493112">format</strong>: Unsupported date extension format, which is a STRING constant. This parameter is mandatory. If there are redundant format strings in <strong id="dli_08_0066__en-us_topic_0000001701650265_b413995293110">format</strong>, only the date value corresponding to the first format string is used. Other format strings are used as separators. For example, <strong id="dli_08_0066__en-us_topic_0000001701650265_b1440413545316">isdate("1234-yyyy", "yyyy-yyyy")</strong> returns <strong id="dli_08_0066__en-us_topic_0000001701650265_b20404195412316">True</strong>.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_row6946849122313"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a3ce3e6a7394b45fa866a00bed6d1a5c3">last_day(string date)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a7de571e88c7b4a7c8d022b0d6a3992bc">DATE</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_ac6e9c9c17336448fa5bd5b57dee081f8">Returns the last day of the month a date belongs to, in the format of <strong id="dli_08_0066__en-us_topic_0000001701650265_b2922935330">yyyy-MM-dd</strong>, for example, <strong id="dli_08_0066__en-us_topic_0000001701650265_b69381965335">2015-08-31</strong>.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_row17946174962310"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p285901412615">lastday(string date)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p4331487207">STRING</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_p53696864718">Returns the last day of the month a date belongs to. The value is of the STRING type and is in the <strong id="dli_08_0066__en-us_topic_0000001701650265_b1284035915393">yyyy-mm-dd hh:mi:ss</strong> format.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_row179472494238"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_af71e952e0db84ca08d36ec29e26825d5">minute(string date)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_ae51c17437a0849eaa5ffd83977e57496">INT</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_af0cc70ef75394f77af8add1926b5b432">Returns the minute (from 0 to 59) of a specified time.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_row1394719494230"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_aa1d5b57c8bc3410a8399563702399e3f">month(string date)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a14b4f5e7eea84094bfc8b50d03094942">INT</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a70ea35377a1a4f23bb62e8c904c169a5">Returns the month (from January to December) of a specified time.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_rb5a8bd21ab874a9d877d9a13796d9e30"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a9c5ce16f36c349cb884c0bf8b787a9ae">months_between(string date1, string date2)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a3368945249b445e7b45cd4b2c1c3168f">DOUBLE</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a836520c819ec48a7b294bc784910c6b0">Returns the month difference between <strong id="dli_08_0066__en-us_topic_0000001701650265_b3918316437">date1</strong> and <strong id="dli_08_0066__en-us_topic_0000001701650265_b209787474312">date2</strong>.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_row270153092419"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a5fcc50d61d4d47e9bb8146be32d426e1">next_day(string start_date, string day_of_week)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_ae792135267f6422abbbdd193b5a60771">DATE</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a291c1f3c5eb0418a8b7d1819f596beb6">Returns the date closest to <strong id="dli_08_0066__en-us_topic_0000001701650265_b1134352818117">day_of_week</strong> after <strong id="dli_08_0066__en-us_topic_0000001701650265_b523631181119">start_date</strong>, in the <strong id="dli_08_0066__en-us_topic_0000001701650265_b1031710496111">yyyy-MM-dd</strong> format. <strong id="dli_08_0066__en-us_topic_0000001701650265_b3700259171119">day_of_week</strong> indicates a day in a week, for example, Monday or Friday.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_row12702123018244"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_p05618544369">quarter(string date)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a2b20bbc405c04f0f89be819033b28eb3">INT</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a0e1f2337d87e4dca8d4188c4744d9c77">Returns the quarter of the date, timestamp, or string, for example, <strong id="dli_08_0066__en-us_topic_0000001701650265_b886919376139">quarter('2015-04-01')=2</strong>.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_row0702143032410"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a1c4bf6ee6a114f5b9dcca2011fc2147c">second(string date)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a5ec965fa707744eb8e282a552c54ce0f">INT</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a3d596561be704f5d976e624092dd5c31">Returns the second (from 0 to 59) of a specified time.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_row1534815251"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p47175306619">to_char(string date, string format)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p816216311259">STRING</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p1716216311252">Converts a date into a string in a specified format.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_row125341811252"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a210a906f5e6c4f0badcfdbf61b378246">to_date(string timestamp)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_p179501818406">DATE</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a6f27cdd52f544f4094f973c9db25541c">Returns the date part of a time string, for example, <strong id="dli_08_0066__en-us_topic_0000001701650265_b157259217152">to_date("1970-01-01 00:00:00") = "1970-01-01"</strong>.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_row553421112518"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p16202027720">to_date1(string date, string format)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p877019441279">STRING</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p1673171813412">The value is of the STRING type, in the <strong id="dli_08_0066__en-us_topic_0000001701650265_b480882510174">yyyy-mm-dd hh:mi:ss</strong> format. If the value of <strong id="dli_08_0066__en-us_topic_0000001701650265_b915215313184">date</strong> or <strong id="dli_08_0066__en-us_topic_0000001701650265_b6152113191820">format</strong> is <strong id="dli_08_0066__en-us_topic_0000001701650265_b17152438184">NULL</strong>, <strong id="dli_08_0066__en-us_topic_0000001701650265_b115220371819">NULL</strong> is returned.</p>
<p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p477018448276">Converts a string in a specified format to a date value.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_row195343182513"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_aaedc3098b86140e8a8eb8c0eecb691d6">to_utc_timestamp(string timestamp, string timezone)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a3ce66b86d7774c54b5d77fa8466a7770">TIMESTAMP</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a8e77ec800b0d4da0823005ead145192c">Converts a timestamp in a given time zone to a UTC timestamp.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_row7534181132512"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a0ff70bef59814c23a9da55d89b8c4110">trunc(string date, string format)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a1e9c536942da45e696ea8ec5147b9b90">DTAE</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_abbb6b723921a4969bc13a7a5d9793923">Resets the date in a specified format. Supported formats are <strong id="dli_08_0066__en-us_topic_0000001701650265_b1451783012219">MONTH/MON/MM</strong> and <strong id="dli_08_0066__en-us_topic_0000001701650265_b1441617368218">YEAR/YYYY/YY</strong>, for example, <strong id="dli_08_0066__en-us_topic_0000001701650265_b3936557192114">trunc('2015-03-17', 'MM') = 2015-03-01</strong>.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_row653415162517"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a87bd755275e549ce9054ea92dfb03577">unix_timestamp(string timestamp, string pattern)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a3b73934e8e7c4ea8bea9c933aa2c4e89">BIGINT</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_afcd259de7089415ba352f1f8c2df3924">Returns a Unix timestamp (the number of seconds since <strong id="dli_08_0066__en-us_topic_0000001701650265_b174751426249">1970-01-01 00:00:00</strong>) as an unsigned integer if the function is called without parameters.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_re2fd8c63d4ee428889e6cd380dd13d2c"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p92111351879">weekday (string date)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p585816530294">INT</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_p38589536294">Returns the day of the current week.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_rc37361bb070c46098ee969d1056c7d6b"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a3756604f910f409889f525cc1bea77c8">weekofyear(string date)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a3d8f481feadf4b9ca11a3d9993ef02e1">INT</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a519b7ee8f95a4bd4b4066cc02c23b848">Returns the week number (from 0 to 53) of a specified date.</p>
</td>
</tr>
<tr id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_rc43a35090d264c88a57e0587b75df209"><td class="cellrowborder" valign="top" width="32.62501443584709%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a27f682432d0d4fcfb0b9f3b0ad98c5cc">year(string date)</p>
</td>
<td class="cellrowborder" valign="top" width="7.991684952072989%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_ac954302529bb4f7da0c7481ddd6ec524">INT</p>
</td>
<td class="cellrowborder" valign="top" width="59.38330061207993%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0066__en-us_topic_0000001701650265_en-us_topic_0206796834_en-us_topic_0093946912_a8bff50cc434a4475bfb9ee58cc80bb03">Returns the year of a specified date.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dli_08_0471.html">Date Functions</a></div>
</div>
</div>