Search code examples
hiveamazon-athena

Convert "Jul 01, 2020" to yyyymmdd(20200701) in aws athena


I have aws athena table and table one column data having like "Jul 01, 2020" , so i want to convert to yyyymmdd format. Please suggest the solution.

-- > Convert "Jul 01, 2020" to yyyymmdd(20200701) in aws athena

Thanks, Prasad


Solution

  • You can use date_format:

    select date_format(from_unixtime(unix_timestamp(col_name, 'MMM dd, yyyy')),
                       'yyyyMMdd') as formatted
    from table;