You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hive.apache.org by Bhavesh Shah <bh...@gmail.com> on 2012/04/02 09:34:56 UTC

How to check for year condition in hive

Hello all,
I am trying to check age in hive.
select * from tbl_name where datediff(date,dob)/365 >= 18;

Is it right to check date condition in hive?
Or do I need to do something else.
Pls suggest me as soon as possible


-- 
Thanks and Regards,
Bhavesh Shah

Re: How to check for year condition in hive

Posted by Bhavesh Shah <bh...@gmail.com>.
Thanks Nitin for your reply.


On Mon, Apr 2, 2012 at 1:19 PM, Nitin Pawar <ni...@gmail.com> wrote:

> that should work provided your columns are in 'yyyy-mm-dd' format and you
> are ok to leave out leap years :)
>
> also its a good idea to have all the mathematical operations in a
> bracketed manner so u can have it like where round(datediff(date,dob)/365)
> >=18
>
>
>
> On Mon, Apr 2, 2012 at 1:04 PM, Bhavesh Shah <bh...@gmail.com>wrote:
>
>> Hello all,
>> I am trying to check age in hive.
>> select * from tbl_name where datediff(date,dob)/365 >= 18;
>>
>> Is it right to check date condition in hive?
>> Or do I need to do something else.
>> Pls suggest me as soon as possible
>>
>>
>> --
>> Thanks and Regards,
>> Bhavesh Shah
>>
>>
>
>
> --
> Nitin Pawar
>
>


-- 
Regards,
Bhavesh Shah

Re: How to check for year condition in hive

Posted by Nitin Pawar <ni...@gmail.com>.
that should work provided your columns are in 'yyyy-mm-dd' format and you
are ok to leave out leap years :)

also its a good idea to have all the mathematical operations in a bracketed
manner so u can have it like where round(datediff(date,dob)/365) >=18



On Mon, Apr 2, 2012 at 1:04 PM, Bhavesh Shah <bh...@gmail.com>wrote:

> Hello all,
> I am trying to check age in hive.
> select * from tbl_name where datediff(date,dob)/365 >= 18;
>
> Is it right to check date condition in hive?
> Or do I need to do something else.
> Pls suggest me as soon as possible
>
>
> --
> Thanks and Regards,
> Bhavesh Shah
>
>


-- 
Nitin Pawar