简体   繁体   中英

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

 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.

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

select date_col ,date_format(date_col, '%m/%d/%Y') FROM <table_name>;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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