[
https://issues.apache.org/jira/browse/DRILL-3610?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14658856#comment-14658856
]
Andries Engelbrecht commented on DRILL-3610:
--------------------------------------------
TIMESTAMPDIFF(SQL_TSI_<interval type>) returns the difference based on the
specified interval between the 2 supplied timestamps, where interval can be
second, minute, hour, day, week, month, quarter or year as an integer.
EXTRACT/Date_Part and Timestamp functions can be used to substitute, but
requires more extensive SQL to achieve the same operation. Can be very
cumbersome in queries with multiple of these operations, also with machine
generated queries.
Date_ADD can be substituted for TIMESTAMPADD, but lacks QUARTER interval
commonly used in financial analysis.
> TimestampAdd/Diff (SQL_TSI_) functions
> --------------------------------------
>
> Key: DRILL-3610
> URL: https://issues.apache.org/jira/browse/DRILL-3610
> Project: Apache Drill
> Issue Type: Improvement
> Components: Functions - Drill
> Reporter: Andries Engelbrecht
> Assignee: Mehant Baid
>
> Add TimestampAdd and TimestampDiff (SQL_TSI) functions for year, quarter,
> month, week, day, hour, minute, second.
> Examples
> SELECT CAST(TIMESTAMPADD(SQL_TSI_QUARTER,1,Date('2013-03-31'), SQL_DATE) AS
> `column_quarter`
> FROM `table_in`
> HAVING (COUNT(1) > 0)
> SELECT `table_in`.`datetime` AS `column1`,
> `table`.`Key` AS `column_Key`,
> TIMESTAMPDIFF(SQL_TSI_MINUTE,to_timestamp('2004-07-04',
> 'yyyy-MM-dd'),`table_in`.`datetime`) AS `sum_datediff_minute`
> FROM `calcs`
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)