You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Thimuth Amarakoon <th...@gmail.com> on 2014/12/21 04:36:06 UTC

How to match three letter month name in Hive queries

Hi,

How can we match a date value like *2014-Dec-20* in unix_timestamp()? The
pattern *yyyy-MM-dd* matches 2014-12-20 format. But yyyy-mmm-dd or
yyyy-m-dd is not doing the trick for matching the month name.

Thanks and regards,
Thimuth

Re: How to match three letter month name in Hive queries

Posted by Thimuth Amarakoon <th...@gmail.com>.
Thanks a lot Furcy. It works.

Regards,
Thimuth

On Sun, Dec 21, 2014 at 4:34 PM, Furcy Pin <fu...@flaminem.com> wrote:

> Hi Thimut,
>
> I believe that the UDF unix_timestamp uses the java class SimpleDateFormat.
> http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html
>
> From the doc, you can see that "m" denotes a minute while "M" denotes a
> month.
> For your problem, "yyyy-MMM-dd" should do the trick.
>
> Regards,
>
> Furcy
>
>
> 2014-12-21 4:36 GMT+01:00 Thimuth Amarakoon <th...@gmail.com>:
>
>> Hi,
>>
>> How can we match a date value like *2014-Dec-20* in unix_timestamp()?
>> The pattern *yyyy-MM-dd* matches 2014-12-20 format. But yyyy-mmm-dd or
>> yyyy-m-dd is not doing the trick for matching the month name.
>>
>> Thanks and regards,
>> Thimuth
>>
>
>

Re: How to match three letter month name in Hive queries

Posted by Furcy Pin <fu...@flaminem.com>.
Hi Thimut,

I believe that the UDF unix_timestamp uses the java class SimpleDateFormat.
http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html

>From the doc, you can see that "m" denotes a minute while "M" denotes a
month.
For your problem, "yyyy-MMM-dd" should do the trick.

Regards,

Furcy


2014-12-21 4:36 GMT+01:00 Thimuth Amarakoon <th...@gmail.com>:

> Hi,
>
> How can we match a date value like *2014-Dec-20* in unix_timestamp()? The
> pattern *yyyy-MM-dd* matches 2014-12-20 format. But yyyy-mmm-dd or
> yyyy-m-dd is not doing the trick for matching the month name.
>
> Thanks and regards,
> Thimuth
>