[Gdal-dev] OGR can't handle Null values in a Date field

Mateusz Loskot mateusz at loskot.net
Fri Jun 23 21:28:42 EDT 2006


Aaron Koning wrote:
> I have just started using a newer version of OGR that includes Date 
> support. (Context: I am importing shapefiles into PostgreSQL using 
> OGR/PHP). Unfortunately, when I there is a Null value in a Date field
>  of the input shapefile OGR bails (after successfully inserting 
> non-null values). From what I can see, it attempts to do an insert 
> with a '00/00/00 00:00:00' value and PostgreSQL states I may need 
> another Date type for this value.

Hi,

I tried to pump your sh
apefile to PostgresSQL using latest ogr2ogr
and I'm also getting date related errors but quite
different.

mloskot:~/tmp$ ogr2ogr -f PostgreSQL PG:dbname=gdal_nulldate dates.shp
ERROR 1: INSERT command for new feature failed.
ERROR:  invalid input syntax for type date: "2001/02/"

Command: INSERT INTO "dates" (WKB_GEOMETRY , "dstrbedate", "dstrbsdate")
 VALUES ('\\001\\003\\000\\000\\000\\001\\000
...
\\267,A', '2001/02/', '2001/02/')
ERROR 1: Terminating translation prematurely after failed
translation of layer dates

As ERROR message says, OGR parses dates as follows:
'2001/02/' and '2001/02/' what seems to be incorrect.

Your shapefile dates are in following format:
DSTRBEDATE DSTRBSDATE
20010207   20010207

I'm not sure why I'm getting this different error when using ogr2ogr
on my Linux box.

May be your PHP script does some additional step, preprocessing?

Frank,

Could you confirm if those dates in the Aaron's shapefile are in correct
format?


Cheers
-- 
Mateusz Loskot
http://mateusz.loskot.net



More information about the Gdal-dev mailing list