In the case here it literally is taking the UNIX timestamp, formatting it in 
yyyy-mm-dd format and then subtracting the specified integer (in this case 1)

Sent from my Lumia 900
________________________________
From: ext Techy Teck
Sent: 8/6/2012 3:37 PM
To: user@hive.apache.org
Subject: Re: (Get the current date -1) in Hive

Thanks Carla for the suggestion, I am currently using Hive 0.6 and that Hive 
version doesn't supports variable substitution with hiveconf variable, so that 
is the reason I was looking for some other alternative-

So you are saying basically, If I add your suggestion in my query like below-

select * from lip_data_quality where dt = 
'date_sub(FROM_UNIXTIME(UNIX_TIMESTAMP(),'yyyy-MM-dd') , 1)';

Then the above query will be interpreted as like below-

select * from lip_data_quality where dt = '2012-08-05';


Am I right? And what does date_sub do here? I am not familiar with that.

Correct me if I am wrong.






On Mon, Aug 6, 2012 at 12:23 PM, 
<carla.stae...@nokia.com<mailto:carla.stae...@nokia.com>> wrote:
If you are just using it in a query, you can do this:
date_sub(FROM_UNIXTIME(UNIX_TIMESTAMP(),'yyyy-MM-dd') , 1)

I generally do my date calculations in a shell script and pass them in with a 
hiveconf variable.

Carla

-----Original Message-----
From: ext Yue Guan [mailto:pipeha...@gmail.com<mailto:pipeha...@gmail.com>]
Sent: Monday, August 06, 2012 15:00
To: user@hive.apache.org<mailto:user@hive.apache.org>
Subject: Re: (Get the current date -1) in Hive

guess you can use sub_date, but you have to get today by some outside script.

On 08/06/2012 02:10 PM, Techy Teck wrote:
> Is there any way to get the current date -1 in Hive means yesterdays
> date always?
>
>
>


Reply via email to