[英]Retrieve only records with today's date from an epoc timestamped column
I have a table which has 'completed' column with the timestamp but the timestamp is in epoch format. 我有一个带有时间戳的“已完成”列的表,但是时间戳为纪元格式。 I am using the below query to translate the epoch time to a normal date but I am not sure how to filter the records that were created today. 我正在使用以下查询将纪元时间转换为正常日期,但是我不确定如何过滤今天创建的记录。 Hope someone can assist. 希望有人能帮忙。
Here is the query I am using: 这是我正在使用的查询:
select name, status, message, completion_status,
TO_CHAR( FROM_TZ( CAST(DATE '1970-01-01' + (1/24/60/60/1000) * completed AS TIMESTAMP), 'America/New_York'), 'yyyy-mm-dd HH24:MI:SS')
as completed from Result;
Found it: 找到了:
select name, status, message, completion_status,
TO_CHAR( FROM_TZ( CAST(DATE '1970-01-01' + (1/24/60/60/1000) * completed AS TIMESTAMP), 'America/New_York'), 'yyyy-mm-dd HH24:MI:SS')
as completed from Result
where TO_CHAR( FROM_TZ( CAST(DATE '1970-01-01' + (1/24/60/60/1000) * completed AS TIMESTAMP), 'America/New_York'), 'yyyy-mm-dd')
LIKE (SELECT TO_CHAR(SYSDATE, 'YYYY-MM-DD') as today_date FROM dual);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.