How to parse month-year string using presto?

Member

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

How to parse month-year string using presto?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by dalton_moen , 4 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.

Related Threads:

How to combine day, month, year fields into a date in presto?
How to validate a string has a proper day month and year with moment.js?
How to parse time string without offset using moment.js?
How to get date string from day number and month number using moment.js?
How to use month and year in to_char in oracle?
How to group news or post by year and month in laravel?