You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Matthieu Labour <ma...@actionx.com> on 2012/10/09 05:54:37 UTC

On hive date functions

Hi
Is it possible with Hive to truncate date to a specified precision?
For example in Postgresql date_trunc('hour',timestamp '2001-02-16
20:38:40') will return 2001-02-16 20:00:00
There is the to_date function in hive
I am trying to achieve the following
select distinct date_trunc('hour', timestamp) as hour, count(*) from table
 group by hour;
Thank you for your help
Matthieu

Re: On hive date functions

Posted by Ruslan Al-Fakikh <me...@gmail.com>.
Hi

Try the hour() function from here:
https://cwiki.apache.org/Hive/languagemanual-udf.html#LanguageManualUDF-DateFunctions

Ruslan

On Tue, Oct 9, 2012 at 7:54 AM, Matthieu Labour <ma...@actionx.com> wrote:
> Hi
> Is it possible with Hive to truncate date to a specified precision?
> For example in Postgresql date_trunc('hour',timestamp '2001-02-16 20:38:40')
> will return 2001-02-16 20:00:00
> There is the to_date function in hive
> I am trying to achieve the following
> select distinct date_trunc('hour', timestamp) as hour, count(*) from table
> group by hour;
> Thank you for your help
> Matthieu
>