How to get year from timestamp in presto sql?

by elisha_langworth , in category: Third Party Scripts , 10 days ago

How to get year from timestamp in presto sql?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by brandy , 9 days 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.