简体   繁体   English

在 AWS Athena 中减去两个时间戳列

[英]Subtracting two timestamps columns in AWS Athena

For my data on S3, I have defined a table in AWS Glue Data Catalog.对于 S3 上的数据,我在 AWS Glue 数据目录中定义了一个表。 This table contains two columns of Timestamp type.该表包含两列Timestamp类型。 I want to subtract these two columns and show it as different column.我想减去这两列并将其显示为不同的列。 I have tried the following query我尝试了以下查询

SELECT  outtime, intime, outtime-intime AS length
FROM database.table
LIMIT 10

However, it gives me the following error.但是,它给了我以下错误。

SYNTAX_ERROR: line 1:66: '-' cannot be applied to timestamp, timestamp SYNTAX_ERROR:第 1:66 行:“-”不能应用于时间戳、时间戳

How can I solve this problem?我怎么解决这个问题? I am using Athena to query data in my S3.我正在使用 Athena 查询 S3 中的数据。

You can use date_diff() , such as:您可以使用date_diff() ,例如:

date_diff(second, intime, outtime)

This returns the result in seconds.这会以秒为单位返回结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM