Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

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

Solved Go to solution
Highlighted

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

New Contributor
 
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

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

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
Highlighted

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

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

Highlighted

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

Master Collaborator

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'
Don't have an account?
Coming from Hortonworks? Activate your account here