Date variable in Hive

2019-09-03 08:40发布

问题:

I am using following code to set date in Hive

SET DATE_DM2=date_sub(from_unixtime(unix_timestamp(),'yyyy/MM/dd'), cast(((from_unixtime(unix_timestamp(), 'u') % 7)+1) as int));

But When I am running the following select statement I am not getting the output

select * from TableName where partitiondate='${DATE_DM2}';

Is there anything wrong with the syntax ?

回答1:

Correct Syntax is :

select * from TableName where partitiondate='${hiveconf:DATE_DM2}';



标签: hive hiveql