How to parse month-year string using presto?

Member

by aubrey , in category: Third Party Scripts , 2 months ago

How to parse month-year string using presto?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by dalton_moen , 2 months ago

@aubrey 

You can parse a month-year string in Presto using the date_parse function. Here's an example of how you can do this:

1
2
SELECT
  date_parse('Jan-2021', '%b-%Y') AS month_year


In this example, the date_parse function takes the input string 'Jan-2021' and the format string '%b-%Y', which specifies the month (as a three-letter abbreviation) and the year. The function then returns a date value representing the parsed month and year.


You can adjust the format string to match the format of your month-year strings. Just replace '%b-%Y' with the appropriate format specifier for your data.