[postgis-users] Problem with date fields in shp2pgsql

Michael Fuhr mike at fuhr.org
Sat Sep 9 07:12:13 PDT 2006


On Fri, Sep 08, 2006 at 04:20:26PM -0600, Bruce Rindahl wrote:
> I am converting a shapefile to PostGIS where one of the fields is a date
> field.  If there is data in the field everything works fine.  However if the
> field is null, shp2pgsql parses the insert statement as:
> 
> INSERT INTO "test" (...,"saledate",...) VALUES (...,'',...);
> 
> pgsql will then throw an error saying:
> 
> ERROR:  invalid input syntax for type date: ""

DBFIsAttributeNULL() in loader/dbfopen.c recognizes only "00000000"
as a NULL date; I'm guessing your shapefile has blanks (0x20) instead
of zeros (0x30).  I wonder if DBFIsAttributeNULL() should perform
a check for strlen(pszValue) == 0 (leading and trailing blanks will
have been stripped) as it currently does for data types other than
Numeric, Float, Date, and Logical.

-- 
Michael Fuhr



More information about the postgis-users mailing list