From a quick test, I can't reproduce. Please provide a minimum shapefile that reproduces the issue

$ cat test.csv
$ cat test.csvt
$ ogr2ogr date_null.shp test.csv
Warning 1: Invalid value type found in record 1 for field dt. This warning will no longer be emitted $ ogr2ogr pg:dbname=autotest date_null.dbf --config PG_USE_COPY YES -overwrite
$ ogrinfo pg:dbname=autotest date_null -al
INFO: Open of `pg:dbname=autotest'
      using driver `PostgreSQL' successful.

Layer name: date_null
Geometry: None
Feature Count: 1
Layer SRS WKT:
FID Column = ogc_fid
id: Integer (9.0)
dt: Date
  id (Integer) = 1
  dt (Date) = (null)


Le 21/11/2023 à 09:24, Matteo Ghetta via gdal-dev a écrit :
Hi all,

I'm trying to import (many) shapefiles into a PG database. I'm facing the following error, but only when PG_USE_COPY is set to YES:

ERROR 1: COPY statement failed.
ERROR:  date/time field value out of range: "0000/00/00"
CONTEXT:  COPY TABLE, line 12682, column DATA_INI: "0000/00/00"

The value in the source shapefile is NULL for some rows. With PG_USE_COPY NO the import works perfectly.

I've found this old ticket, that seems to describe this exact issue, and is marked as resolved:

Tested with:

* GDAL 3.2.2, released 2021/03/05
* GDAL 3.7.3, released 2023/10/30

Do you have any ideas about what is causing this?

Cheers and thanks

gdal-dev mailing list

My software is free, but my time generally not.

gdal-dev mailing list

Reply via email to