PostgreSQL convert month name to number
问题 I have a query that returns a field as month and year for example "Nov 2015" I want to get the number for the month, here I have to get number as "11". 回答1: You can use the to_date function that can parse input in a certain format into a 'real' date. Then with this date you can extract the month from it. select EXTRACT(MONTH FROM to_date('Nov 2015', 'Mon YYYY')) See http://www.postgresql.org/docs/current/static/functions-formatting.html for the formatting syntax and http://www.postgresql.org