- Newest
- Most votes
- Most comments
In Athena, the TIMESTAMP data type is used to represent points in time, but it's important to note that it doesn't inherently include timezone information. By default, Athena treats all timestamps as UTC. If you need to display or work with the data in a different timezone, such as Singapore Time (UTC+8), you have to explicitly convert the timestamps in your queries.
You can use the AT TIME ZONE clause in SQL queries to convert timestamps to a specific timezone. For example, to convert a timestamp column to Singapore Time, you would use a query similar to:
SELECT shipment_time AT TIME ZONE 'Asia/Singapore' as local_shipment_time FROM orders;
This query will convert the shipment_time from UTC to Singapore Time.
Furthermore, the Redshift CONVERT_TIMEZONE function can be used for converting a timestamp from one timezone to another. This function can be particularly useful if you're dealing with data warehousing scenarios where you need to convert timestamps between different timezones. The syntax for using this function is:
CONVERT_TIMEZONE('source_timezone', 'target_timezone', 'timestamp')
For instance, to convert from UTC to Singapore Time, you might use:
SELECT CONVERT_TIMEZONE('UTC', 'Asia/Singapore', shipment_time) FROM orders;
For more information, you can refer to Redshift CONVERT_TIMEZONE function.
Let me know if you have any further questions.
Regards!
Mina
Relevant content
- Accepted Answerasked 3 years ago
- asked 3 years ago
- AWS OFFICIALUpdated 5 months ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 6 months ago