gpt4 book ai didi

hive - 以 yyyymmdd 格式在配置单元中显示今天的日期

转载 作者:行者123 更新时间:2023-12-02 15:24:13 39 4
gpt4 key购买 nike

我正在尝试编写一个配置单元查询以从今天的分区中获取数据。这是我的查询:

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 - 以 yyyymmdd 格式在配置单元中显示今天的日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31591971/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com