Sample Header Ad - 728x90

How to store date with only four digital format?

-1 votes
1 answer
823 views
In postgresql the date format is yyyy-mm-dd by default. create table sample( quant int,year date); The data file is stored data.csv in csv format such as: quant,year 10,2019 12,2020 13,2021 Try to import it with : copy sample(quant,year) from 'data.csv' (DELIMITER ',', FORMAT 'csv', HEADER); It encounter an error: ERROR: invalid input syntax for type date: "2019" CONTEXT: COPY sample, line 2, column year: "2019" It is the only way to set year's type as int? create table sample( quant int,year int); How can import the data.csv without rewrite year's type?
Asked by showkey (386 rep)
Jan 28, 2022, 01:55 AM
Last activity: Jan 28, 2022, 07:23 AM