[英]get date without time from athena table using s3 bucket
As i have the table in athena with multiple columns.因为我在雅典娜的桌子上有多列。 In that table one of the column named such as date_col with below format.
在该表中,名为 date_col 的列之一具有以下格式。
date_col
1/13/2022 3:00:16 PM
1/13/2022 3:00:13 PM
1/13/2022 2:00:16 PM
1/13/2022 2:15:16 PM
From the above date_col records, I want to get the only date without time part.从上面的 date_col 记录中,我想得到唯一没有时间部分的日期。
Here it is i am using the query:这是我正在使用的查询:
select date_col, date_format(date_col, '%m/%d/%Y') from 'test'.sample_table'
But getting below error like:但是低于以下错误:
SYNTAX_ERROR: line 1:25: Unexpected parameters (varchar, varchar(8)) for function date_format. Expected: date_format(timestamp with time zone, varchar(x)) , date_format(timestamp, varchar(x))
Required format should be like:要求的格式应该是这样的:
date_col
1/13/2022
1/13/2022
1/13/2022
1/13/2022
I used different ways to get that result.我用了不同的方法来得到那个结果。 But, I couldn't get the required format.
但是,我无法获得所需的格式。 Can you please help me for that.
你能帮我吗? Thanks in advance.
提前致谢。
Please try with the date_format function请尝试使用 date_format function
select date_col ,date_format(date_col, '%m/%d/%Y') FROM <table_name>;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.