You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Soham Sardar <so...@gmail.com> on 2012/06/25 09:28:23 UTC

querying with datetime in hive and mysql

i have a problem with querying with the datetime format of mysql and
then it has to stored in the string format and nothing else and then
when i try to query in it say name the users who logged between 10 to
11 am in time coz i am using  LIKE which matches pattern and then i
cant give like for all the time instances ... can some one help me out
with this as to how to implement these types of querying both in HIVE
and mySql

Re: querying with datetime in hive and mysql

Posted by Bejoy KS <be...@yahoo.com>.
Hi soham

Since the date is stored as String in hive you can use the date functions to get the hour. 

Just check whether the hour falls in between 10 and 11 AM

In simple terms,
WHERE hour('date')>= 10 AND hour('date') <= 11 

If you want to consider the date as well then you need to play with the unix timestamp value or extract the date and include the logic in where clause.

 
Regards
Bejoy KS

Sent from handheld, please excuse typos.

-----Original Message-----
From: Soham Sardar <so...@gmail.com>
Date: Mon, 25 Jun 2012 12:58:23 
To: <us...@hive.apache.org>
Reply-To: user@hive.apache.org
Subject: querying with datetime in hive and mysql

i have a problem with querying with the datetime format of mysql and
then it has to stored in the string format and nothing else and then
when i try to query in it say name the users who logged between 10 to
11 am in time coz i am using  LIKE which matches pattern and then i
cant give like for all the time instances ... can some one help me out
with this as to how to implement these types of querying both in HIVE
and mySql