I have a Athena SQL Query where I am calculating some delivery date like below.
CASE WHEN eventtime IS NOT NULL
AND eventtime != '' THEN
date_format(from_iso8601_timestamp (eventtime), '%Y-%m-%d %H:%i:%s')
ELSE
NULL
END AS computation_date
When I download the data as CSV and try to open an Excel ], I cannot see the seconds values in the Excel (due to some default format). To fix this, I am trying to concatenate the ‘ string to the date value so that the CSV data will consider this as a string. I tried with array agg and array join, but it’s not working properly for me.
example:
Sample data 2024-06-04 12:39:00 , 2024-06-04 12:11:00 this is the output data in AWS Athena SQL
in Excel i can able to see 2024-06-04 12:39 ,2024-06-04 12:11 .
trying to add string "’" to the value ‘2024-06-04 12:39:00 , ‘2024-06-04 12:11:00
2
Answers
If the goal is to add
'
character to the output you can use another'
to escape it in the output format:Output:
There is no need to do that in the code. The problem is with Excel and the default way it’s showing values. To fix that and to see the seconds, you should:
Number
tab select Category->CustomType
enter yyyy-mm-dd H:mm:ssThis will tell Excel to show you date formatted the way you want, including seconds