How to get year from timestamp in presto sql?

by elisha_langworth , in category: Third Party Scripts , 4 months ago

How to get year from timestamp in presto sql?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by brandy , 4 months ago

@elisha_langworth 

You can extract the year from a timestamp in Presto SQL using the date_format function. Here's an example query to get the year from a timestamp column:

1
2
3
SELECT 
   date_format(your_timestamp_column, '%Y') AS year
FROM your_table;


Replace your_timestamp_column with the name of the column containing your timestamp data and your_table with the name of your table.


This query will extract the year from your timestamp data and return it as a separate column named year.

Related Threads:

How to get latest 3 months records in presto sql?
How to parse month-year string using presto?
How to convert timestamp to date in presto?
How to specify timestamp format in oracle sql?
How to combine day, month, year fields into a date in presto?
How to left join in presto sql?