How to combine day, month, year fields into a date in presto?

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

How to combine day, month, year fields into a date in presto?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by denis , 4 months ago

@mallory_cormier 

In Presto, you can combine day, month, and year fields into a date using the date function. Here is an example query that shows how to combine these fields:

1
2
SELECT date_parse(concat(year_column, '-', month_column, '-', day_column), '%Y-%m-%d') AS combined_date
FROM your_table_name;


In this query:

  • year_column, month_column, and day_column are the names of the columns in your table that store the year, month, and day values.
  • date_parse function is used to parse the combined string ('YYYY-MM-DD') into a date format.
  • The concat function is used to concatenate the year, month, and day values into a single string with the format 'YYYY-MM-DD'.


This query will return a new column combined_date containing the combined date value.

Related Threads:

How to validate a string has a proper day month and year with moment.js?
How to parse month-year string using presto?
How to plot date/month/year range in chart.js?
How to get date string from day number and month number using moment.js?
How to get month name from date in presto?
How to use month and year in to_char in oracle?