sql - 将 Unixtime 转换为 MMddyyyy
问题描述
我正在尝试将具有 unixtime(例如 1542862806000)的列转换为常规 DTS
select unix_timestamp(column_name) from table;
但我得到错误:
AnalysisException: No matching function with signature: unix_timestamp(BIGINT).
我的列类型是 bigint
解决方案
你要找的from_unixtime
不是unix_timestamp
。
select from_unixtime(cast(column_name/1000 as bigint),'MMddyyyy')
from table
unix_timestamp
将日期/日期格式字符串转换为表示自UTCbigint
以来的秒数。1970-01-01 00:00:00
from_unixtime
接受bigint
输入并将其转换为所需的日期格式。
推荐阅读
- javascript - 减少没有初始值的空数组
- java - 让我的代码高效循环 10 000 000 000 次的任何想法
- php - 检查用户是否在给定时间在php中工作
- node.js - SyntaxError:意外的令牌
- amazon-web-services - AWS RDS VPC 安全性
- c++ - 如何对同一数组索引下的结构成员进行排序?
- php - Yii2分页只有上一个和下一个按钮隐藏页码
- laravel - Laravel 和 Google 应用引擎 flex 环境。在 nginx 配置中设置缓存控制不起作用
- swift - Swift 以编程方式设置 textview 字体仅适用于键入的新文本而不是所有文本
- angular - 单元测试:如何使用 Angular + Jasmine 模拟窗口对象的 innerWidth 属性?