Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

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

avatar
Visitor
 
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'