views:

554

answers:

1

I have se the below date format in the codeignitor config.php

$config['log_date_format'] = 'd/m/Y';

Ans wen I enter '30/04/2010' in the text input field and tried to save, got he following error

ERROR: date/time field value out of range: "30/04/2010" HINT: Perhaps you need a different "datestyle" setting

Corresponding query is below

UPDATE "assignments" SET "id" = '2', "name" = 'Stadium complex', "date_started" = '30/04/2010', "date_completed" = NULL, "assigned_id" = '9', "customer_id" = '4', "description" = NULL WHERE "id" = '2'

How can I solve his? Do I need to format the date before save?

+1  A: 

The 'log_date_format' setting in config.php is the date format for entries in your CodeIgniter log file. It does not have anything to do with the error you are getting.

The error is coming from your PostgreSQL database server. The date format you are trying to use in your query is not one that PostgreSQL is expecting. You can find out what date format PostgreSQL is expecting by running the command :

SHOW DATESTYLE;

You can tell PostgresSQL what date format you intend to use by executing the command

SET DATESTYLE TO '<SOME_DATESTYLE>';

More information can be found in the PostgreSQL manual.

Stephen Curran