'How to extract date from string

I'm working on PostgreSQL with SQL.

I have a column date that is a string and I want to extract the month:

enter image description here

I tried:

SELECT EXTRACT(MONTH FROM cast(date as date)) FROM table_name ;

I got:

ERROR: ERREUR: syntaxe en entrée invalide pour le type date : « janvier 2020 »

Can anyone help me please?



Solution 1:[1]

try

select  
    split_part(date, ' ', 2) as month
from table_name

.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Pooya