Impala SQL将所有大于日期 - 日期列的所有记录分配为毫秒

发布于 2025-02-05 02:19:30 字数 1026 浏览 4 评论 0原文

I'm looking to retrieve all rows in a table where last_modified_date is within the last 30 days. The date field is int and appears to be in milliseconds so not sure about the where condition. So a few steps here, convert the date field to standard date time then apply a date.或者,花时间并将所有记录取回30天。

SELECT  last_modified_date, 
        from_timestamp(CAST(CAST(last_modified_date as decimal(30,0))/1000 AS timestamp), "yyyy-MM-dd HH:mm:ss.SSS") as "Completed_Date" 
FROM    helix_access.chg_infrastructure_change limit 100;

我尝试了一个基本条件,但没有返回任何内容:

select from_timestamp(CAST(CAST(last_modified_date as decimal(30,0))/1000 AS timestamp), "yyyy-MM-dd HH:mm:ss.SSS") as "Completed_Date" 
from helix_access.chg_infrastructure_change limit 100;
where (Completed_Date) >= 2022-05-09 00:00:00.000

I'm looking to retrieve all rows in a table where last_modified_date is within the last 30 days. The date field is int and appears to be in milliseconds so not sure about the where condition. So a few steps here, convert the date field to standard date time then apply a date. Alternatively take the current time and get all records back 30 days.

SELECT  last_modified_date, 
        from_timestamp(CAST(CAST(last_modified_date as decimal(30,0))/1000 AS timestamp), "yyyy-MM-dd HH:mm:ss.SSS") as "Completed_Date" 
FROM    helix_access.chg_infrastructure_change limit 100;

enter image description here

I tried a basic where condition but it's not returning anything:

select from_timestamp(CAST(CAST(last_modified_date as decimal(30,0))/1000 AS timestamp), "yyyy-MM-dd HH:mm:ss.SSS") as "Completed_Date" 
from helix_access.chg_infrastructure_change limit 100;
where (Completed_Date) >= 2022-05-09 00:00:00.000

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浮生未歇 2025-02-12 02:19:30

尝试此查询:

SELECT  last_modified_date, 
        FROM_UNIXTIME(last_modified_date), "yyyy-MM-dd HH:mm:ss.SSS") as "Completed_Date" 
FROM helix_access.chg_infrastructure_change 
WHERE FROM_UNIXTIME(last_modified_date), "yyyy-MM-dd HH:mm:ss.SSS") >= '2022-05-09 00:00:00.000'
limit 100;

Try this query:

SELECT  last_modified_date, 
        FROM_UNIXTIME(last_modified_date), "yyyy-MM-dd HH:mm:ss.SSS") as "Completed_Date" 
FROM helix_access.chg_infrastructure_change 
WHERE FROM_UNIXTIME(last_modified_date), "yyyy-MM-dd HH:mm:ss.SSS") >= '2022-05-09 00:00:00.000'
limit 100;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文