Skip to content

Instantly share code, notes, and snippets.

@tfentonz
Created June 13, 2019 21:53
Show Gist options
  • Save tfentonz/168b7c2ea2acaa9d3e1c2dae943fa3aa to your computer and use it in GitHub Desktop.
Save tfentonz/168b7c2ea2acaa9d3e1c2dae943fa3aa to your computer and use it in GitHub Desktop.
Athena Date and Time Functions
-- [SQL Queries, Functions, and Operators](https://docs.aws.amazon.com/athena/latest/ug/functions-operators-reference-section.html)
SELECT
from_iso8601_timestamp(time) as new_time,
date_format(from_iso8601_timestamp(time), '%Y') AS year,
hour(from_iso8601_timestamp(time)) AS hour,
from_iso8601_timestamp(time) at time zone 'Pacific/Auckland' as nzst_time,
hour(from_iso8601_timestamp(time) at time zone 'Pacific/Auckland') AS nzst_hour,
minute(from_iso8601_timestamp(time) at time zone 'Pacific/Auckland') AS nzst_minute,
*
FROM alb_logs;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment