Date insertion in PostgreSQL

1

I would like to know how to configure Postgre to accept date entries as follows: "12122016" .

I know that with the same "spelling" it is possible with YMD but I would like to know how to configure it to accept it.

Thanks in advance for your attention.

    
asked by anonymous 03.03.2017 / 19:14

1 answer

1

Willian,

Postgres has the datestyle parameter that allows you to configure the default date format of your cluster (if configured in postgresql.conf) or its database ( ALTER DATABASE database_name SET datestyle TO "ISO, DMY"; ), but I did not find anything in that ddMMyyyy format, example. The default for this parameter is: ISO, DMY

However, when performing the INSERT you can use the to_date function to convert this information.

insert into nome_tabela (campo_data) values (to_date('12122016','ddMMyyyy'));

link link

    
03.03.2017 / 23:47