Home > Software engineering >  How to extract date from string
How to extract date from string

Time:03-26

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?

CodePudding user response:

try

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

.

  • Related