以 yyyymmdd 格式在配置单元中显示今天的日期
format for today's date in hive in yyyymmdd format
我正在尝试编写配置单元查询以从今天的分区中获取数据。这是我的查询:
select * from testtable
where data_dt ='date +%Y%m%d';
我需要帮助将日期转换为 yyyyMMdd
格式。
非常感谢。
试试这个:
select *
from mytable
where mydate=regexp_replace(to_date(from_unixtimestamp())),'-','')
;
当我测试使用时:
select regexp_replace(to_date(from_unixtimestamp())),'-','') as yyyyMMdd from dual;
我得到输出:20150723
hive 中有几个函数可用于以所需格式检索今天的日期。
试试这个:
select from_unixtime(unix_timestamp(),'yyyyMMdd') 来自 table_name;
unix_timestamp(): 这个函数 return 是一个 unix 时间戳。
from_unixtime(): 此函数用于 return 所需格式的日期。
有关 hive 中内置函数的更多信息,请尝试
显示函数;
描述函数function_name;
描述函数扩展function_name;
我正在尝试编写配置单元查询以从今天的分区中获取数据。这是我的查询:
select * from testtable
where data_dt ='date +%Y%m%d';
我需要帮助将日期转换为 yyyyMMdd
格式。
非常感谢。
试试这个:
select *
from mytable
where mydate=regexp_replace(to_date(from_unixtimestamp())),'-','')
;
当我测试使用时:
select regexp_replace(to_date(from_unixtimestamp())),'-','') as yyyyMMdd from dual;
我得到输出:20150723
hive 中有几个函数可用于以所需格式检索今天的日期。
试试这个:
select from_unixtime(unix_timestamp(),'yyyyMMdd') 来自 table_name;
unix_timestamp(): 这个函数 return 是一个 unix 时间戳。
from_unixtime(): 此函数用于 return 所需格式的日期。
有关 hive 中内置函数的更多信息,请尝试
显示函数;
描述函数function_name;
描述函数扩展function_name;