简体   繁体   English

从带有时间戳的时间戳列中检索只有今天的日期的记录

[英]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.

相关问题 如何仅从SQL Server的XML列中检索日期大于今天的日期的行? - How can I only retrieve rows with dates greater than today's date from an XML column in SQL Server? 如何仅为具有今天日期的记录创建唯一索引? - How to create unique index only for records with today's date? MySQL使用DATETIME字段中的DATE返回今天的记录 - MySQL Return Today's Records Using DATE from DATETIME Field 选择将从今天的日期起一个月后到期的记录 - Select records going to expire in a month from today's date 仅当列值是今天的日期时才需要触发触发器 - Trigger needs to fire only when column value is today's date 在Oracle SQL中,将字符串日期列与今天的日期进行比较。 仅考虑月份和日期 - In Oracle SQL, compare string date column with today's date. Considering only Month and Day 知道如何从今天的日期检索属于前一周的日期吗? - Any idea how can i retrieve dates that belong to the week before from today's date? 如何仅使用自定义日期设置选择今天的记录 - how to select records for today only with custom date settings 在今天的日期和今年的指定月份之间搜索记录 - Searching records between today's date and a specified month of this year 我需要根据今天的日期生成当前一周的记录 - I need to generate records for current week based on today's date
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM