Support Questions

Find answers, ask questions, and share your expertise

Hive trunc function to extract quarter just like sql trunc(column,'q)

avatar
New Contributor
 
1 ACCEPTED SOLUTION

avatar

Do you need quarter of the year for some date, timestamp, or string? If yes then Hive already has a built-in date functions defined for it :

quarter(date/timestamp/string)

https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF

View solution in original post

2 REPLIES 2

avatar

Do you need quarter of the year for some date, timestamp, or string? If yes then Hive already has a built-in date functions defined for it :

quarter(date/timestamp/string)

https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF

avatar

In the Hive version prior to 2.2.0 there is no function available, I added support for it recently, see HIVE-16234. Example

SELECT trunc('2017-03-15', 'Q');
'2017-01-01'